42#include "llvm/ADT/ScopeExit.h"
43#include "llvm/ADT/SmallString.h"
44#include "llvm/ADT/STLExtras.h"
45#include "llvm/ADT/StringExtras.h"
61class CheckDefaultArgumentVisitor
64 const Expr *DefaultArg;
67 CheckDefaultArgumentVisitor(
Sema &S,
const Expr *DefaultArg)
68 : S(S), DefaultArg(DefaultArg) {}
73 bool VisitLambdaExpr(
const LambdaExpr *Lambda);
78bool CheckDefaultArgumentVisitor::VisitExpr(
const Expr *
Node) {
79 bool IsInvalid =
false;
80 for (
const Stmt *SubStmt :
Node->children())
81 IsInvalid |= Visit(SubStmt);
88bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(
const DeclRefExpr *DRE) {
90 if (
const auto *Param = dyn_cast<ParmVarDecl>(
Decl)) {
101 diag::err_param_default_argument_references_param)
103 }
else if (
const auto *VDecl = dyn_cast<VarDecl>(
Decl)) {
115 if (VDecl->isLocalVarDecl() && !DRE->
isNonOdrUse())
117 diag::err_param_default_argument_references_local)
125bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(
const CXXThisExpr *ThisE) {
130 diag::err_param_default_argument_references_this)
134bool CheckDefaultArgumentVisitor::VisitPseudoObjectExpr(
139 if (
const auto *OVE = dyn_cast<OpaqueValueExpr>(E)) {
140 E = OVE->getSourceExpr();
141 assert(E &&
"pseudo-object binding without source expression?");
149bool CheckDefaultArgumentVisitor::VisitLambdaExpr(
const LambdaExpr *Lambda) {
156 return S.
Diag(Lambda->
getBeginLoc(), diag::err_lambda_capture_default_arg);
169 Proto = Self->ResolveExceptionSpec(CallLoc, Proto);
179 if (EST ==
EST_None && Method->hasAttr<NoThrowAttr>())
186 llvm_unreachable(
"should not see unresolved exception specs here");
215 "should not generate implicit declarations for dependent cases");
219 assert(EST ==
EST_Dynamic &&
"EST case not considered earlier.");
221 "Shouldn't collect exceptions when throw-all is guaranteed.");
225 if (ExceptionsSeen.insert(Self->Context.getCanonicalType(E)).second)
226 Exceptions.push_back(E);
254 if (Self->canThrow(S))
260 if (RequireCompleteType(Param->getLocation(), Param->getType(),
261 diag::err_typecheck_decl_incomplete_type))
276 if (Result.isInvalid())
278 Arg = Result.getAs<
Expr>();
280 CheckCompletedExpr(Arg, EqualLoc);
281 Arg = MaybeCreateExprWithCleanups(Arg);
289 Param->setDefaultArg(Arg);
293 UnparsedDefaultArgInstantiationsMap::iterator InstPos
294 = UnparsedDefaultArgInstantiations.find(Param);
295 if (InstPos != UnparsedDefaultArgInstantiations.end()) {
296 for (
unsigned I = 0,
N = InstPos->second.size(); I !=
N; ++I)
297 InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
300 UnparsedDefaultArgInstantiations.erase(InstPos);
310 if (!param || !DefaultArg)
314 UnparsedDefaultArgLocs.erase(Param);
317 Param->setInvalidDecl();
319 EqualLoc, Param->getType().getNonReferenceType(),
VK_PRValue));
324 Diag(EqualLoc, diag::err_param_default_argument)
330 if (DiagnoseUnexpandedParameterPack(DefaultArg, UPPC_DefaultArgument)) {
337 if (Param->isParameterPack()) {
338 Diag(EqualLoc, diag::err_param_default_argument_on_parameter_pack)
341 Param->setDefaultArg(
nullptr);
345 ExprResult Result = ConvertParamDefaultArgument(Param, DefaultArg, EqualLoc);
346 if (Result.isInvalid())
349 DefaultArg = Result.getAs<
Expr>();
352 CheckDefaultArgumentVisitor DefaultArgChecker(*
this, DefaultArg);
353 if (DefaultArgChecker.Visit(DefaultArg))
356 SetParamDefaultArgument(Param, DefaultArg, EqualLoc);
370 Param->setUnparsedDefaultArg();
371 UnparsedDefaultArgLocs[Param] = ArgLoc;
382 Param->setInvalidDecl();
383 UnparsedDefaultArgLocs.erase(Param);
385 EqualLoc, Param->getType().getNonReferenceType(),
VK_PRValue));
405 if (MightBeFunction) {
409 MightBeFunction =
false;
412 for (
unsigned argIdx = 0, e = chunk.
Fun.
NumParams; argIdx != e;
415 if (Param->hasUnparsedDefaultArg()) {
416 std::unique_ptr<CachedTokens> Toks =
419 if (Toks->size() > 1)
421 Toks->back().getLocation());
423 SR = UnparsedDefaultArgLocs[Param];
424 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
426 }
else if (Param->getDefaultArg()) {
427 Diag(Param->getLocation(), diag::err_param_default_argument_nonfunc)
428 << Param->getDefaultArg()->getSourceRange();
429 Param->setDefaultArg(
nullptr);
433 MightBeFunction =
false;
440 return P->hasDefaultArg() && !P->hasInheritedDefaultArg();
461 for (; PrevForDefaultArgs;
471 if (S && !isDeclInScope(PrevForDefaultArgs, ScopeDC, S) &&
509 for (
unsigned p = 0, NumParams = PrevForDefaultArgs
512 p < NumParams; ++p) {
516 bool OldParamHasDfl = OldParam ? OldParam->
hasDefaultArg() :
false;
519 if (OldParamHasDfl && NewParamHasDfl) {
520 unsigned DiagDefaultParamID =
521 diag::err_param_default_argument_redefinition;
526 if (getLangOpts().MicrosoftExt) {
536 DiagDefaultParamID = diag::ext_param_default_argument_redefinition;
554 for (
auto Older = PrevForDefaultArgs;
556 Older = Older->getPreviousDecl();
557 OldParam = Older->getParamDecl(p);
562 }
else if (OldParamHasDfl) {
580 }
else if (NewParamHasDfl) {
584 diag::err_param_default_argument_template_redecl)
587 diag::note_template_prev_declaration)
618 if (Record->getDescribedClassTemplate())
620 else if (isa<ClassTemplatePartialSpecializationDecl>(Record))
627 diag::err_param_default_argument_member_template_redecl)
637 if (isa<CXXConstructorDecl>(New) &&
640 OldSM = getSpecialMember(cast<CXXMethodDecl>(Old));
641 if (NewSM != OldSM) {
644 Diag(NewParam->
getLocation(), diag::err_default_arg_makes_ctor_special)
679 if (isa<CXXDeductionGuideDecl>(New) &&
691 Diag(New->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
705 CheckForFunctionRedefinition(New, OldDefinition);
725 if (!TemplateParamLists.empty()) {
728 Diag(TemplateParamLists.front()->getTemplateLoc(),
729 diag::err_decomp_decl_template);
735 ? diag::ext_decomp_decl
736 : D.
getContext() == DeclaratorContext::Condition
737 ? diag::ext_decomp_decl_cond
738 : diag::warn_cxx14_compat_decomp_decl)
756 if (
auto SCS = DS.getStorageClassSpec()) {
759 CPlusPlus20SpecifierLocs.push_back(DS.getStorageClassSpecLoc());
762 BadSpecifierLocs.push_back(DS.getStorageClassSpecLoc());
765 if (
auto TSCS = DS.getThreadStorageClassSpec()) {
767 CPlusPlus20SpecifierLocs.push_back(DS.getThreadStorageClassSpecLoc());
769 if (DS.hasConstexprSpecifier()) {
770 BadSpecifiers.push_back(
772 BadSpecifierLocs.push_back(DS.getConstexprSpecLoc());
774 if (DS.isInlineSpecified()) {
775 BadSpecifiers.push_back(
"inline");
776 BadSpecifierLocs.push_back(DS.getInlineSpecLoc());
778 if (!BadSpecifiers.empty()) {
779 auto &&Err =
Diag(BadSpecifierLocs.front(), diag::err_decomp_decl_spec);
780 Err << (
int)BadSpecifiers.size()
781 << llvm::join(BadSpecifiers.begin(), BadSpecifiers.end(),
" ");
784 for (
auto Loc : BadSpecifierLocs)
786 }
else if (!CPlusPlus20Specifiers.empty()) {
787 auto &&Warn =
Diag(CPlusPlus20SpecifierLocs.front(),
789 ? diag::warn_cxx17_compat_decomp_decl_spec
790 : diag::ext_decomp_decl_spec);
791 Warn << (
int)CPlusPlus20Specifiers.size()
792 << llvm::join(CPlusPlus20Specifiers.begin(),
793 CPlusPlus20Specifiers.end(),
" ");
794 for (
auto Loc : CPlusPlus20SpecifierLocs)
806 Diag(DS.getVolatileSpecLoc(),
807 diag::warn_deprecated_volatile_structured_binding);
813 UPPC_DeclarationType))
827 ? diag::err_decomp_decl_parens
828 : diag::err_decomp_decl_type)
846 ForVisibleRedeclaration);
852 Previous.getFoundDecl()->isTemplateParameter()) {
862 ? getShadowedDeclaration(BD,
Previous)
867 FilterLookupForScope(
Previous, DC, S, ConsiderLinkage,
871 auto *Old =
Previous.getRepresentativeDecl();
872 Diag(B.NameLoc, diag::err_redefinition) << B.Name;
873 Diag(Old->getLocation(), diag::note_previous_definition);
875 CheckShadow(BD, ShadowedDecl,
Previous);
877 PushOnScopeChains(BD, S,
true);
879 ParsingInitForAutoVars.insert(BD);
887 ForVisibleRedeclaration);
890 bool AddToScope =
true;
892 ActOnVariableDeclarator(S, D, DC, TInfo,
Previous,
896 CurContext->addHiddenDecl(New);
899 if (isInOpenMPDeclareTargetContext())
900 checkDeclIsAllowedInOpenMPTarget(
nullptr, New);
910 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
923 E = GetInit(Loc, E.
get(), I++);
926 B->setBinding(ElemType, E.
get());
935 const llvm::APSInt &NumElems,
938 S,
Bindings, Src, DecompType, NumElems, ElemType,
969 S,
Bindings, Src, DecompType, llvm::APSInt::get(2),
973 return S.CreateBuiltinUnaryOp(Loc, I ? UO_Imag : UO_Real, Base);
981 llvm::raw_svector_ostream OS(SS);
988 TemplateParameterList::shouldIncludeTypeForArgument(
993 return std::string(OS.str());
1000 auto DiagnoseMissing = [&] {
1010 return DiagnoseMissing();
1020 return DiagnoseMissing();
1021 if (Result.isAmbiguous())
1026 Result.suppressDiagnostics();
1028 S.
Diag(Loc, diag::err_std_type_trait_not_class_template) << Trait;
1040 Loc, TraitTy, DiagID,
1047 assert(RD &&
"specialization of class template is not a class?");
1066namespace {
enum class IsTupleLike { TupleLike, NotTupleLike,
Error }; }
1069 llvm::APSInt &Size) {
1071 S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
1084 return IsTupleLike::NotTupleLike;
1093 : R(R), Args(Args) {}
1096 return S.
Diag(Loc, diag::err_decomp_decl_std_tuple_size_not_constant)
1100 } Diagnoser(R, Args);
1105 return IsTupleLike::Error;
1109 return IsTupleLike::Error;
1111 return IsTupleLike::TupleLike;
1126 S, R, Loc,
"tuple_element", Args,
1127 diag::err_decomp_decl_std_tuple_element_not_specialized))
1133 S.
Diag(Loc, diag::err_decomp_decl_std_tuple_element_not_specialized)
1145struct InitializingBinding {
1154 ~InitializingBinding() {
1163 const llvm::APSInt &TupleSize) {
1165 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1181 bool UseMemberGet =
false;
1191 dyn_cast<FunctionTemplateDecl>(D->getUnderlyingDecl())) {
1193 if (TPL->
size() != 0 &&
1194 isa<NonTypeTemplateParmDecl>(TPL->
getParam(0))) {
1196 UseMemberGet =
true;
1205 InitializingBinding InitContext(S, B);
1228 MemberGet, &Args,
nullptr);
1262 B->getDeclName().getAsIdentifierInfo(), RefType,
1266 RefVD->setImplicit();
1268 RefVD->setInlineSpecified();
1269 RefVD->getLexicalDeclContext()->addHiddenDecl(RefVD);
1274 E = Seq.
Perform(S, Entity, Kind, Init);
1280 RefVD->setInit(E.
get());
1289 B->setBinding(T, E.
get());
1304 return Specifier->getType()->getAsCXXRecordDecl()->hasDirectFields();
1313 ClassWithFields = RD;
1325 for (
auto &
P : Paths) {
1329 BestPath->back().Base->getType())) {
1331 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1332 <<
false << RD << BestPath->back().Base->getType()
1333 <<
P.back().Base->getType();
1335 }
else if (
P.Access < BestPath->
Access) {
1341 QualType BaseType = BestPath->back().Base->getType();
1343 S.
Diag(Loc, diag::err_decomp_decl_ambiguous_base)
1350 *BestPath, diag::err_decomp_decl_inaccessible_base);
1353 ClassWithFields = BaseType->getAsCXXRecordDecl();
1361 S.
Diag(Loc, diag::err_decomp_decl_multiple_bases_with_members)
1362 << (ClassWithFields == RD) << RD << ClassWithFields
1363 << Paths.front().back().Base->getType();
1374 diag::err_incomplete_type))
1386 auto DiagnoseBadNumberOfBindings = [&]() ->
bool {
1387 unsigned NumFields = llvm::count_if(
1388 RD->
fields(), [](
FieldDecl *FD) { return !FD->isUnnamedBitfield(); });
1389 assert(
Bindings.size() != NumFields);
1390 S.
Diag(Src->
getLocation(), diag::err_decomp_decl_wrong_number_bindings)
1400 for (
auto *FD : RD->
fields()) {
1401 if (FD->isUnnamedBitfield())
1406 if (!FD->getDeclName()) {
1413 if (FD->isAnonymousStructOrUnion()) {
1416 S.
Diag(FD->getLocation(), diag::note_declared_at);
1425 return DiagnoseBadNumberOfBindings();
1436 BasePair.
getAccess(), FD->getAccess())));
1459 if (FD->isMutable())
1465 return DiagnoseBadNumberOfBindings();
1507 llvm::APSInt TupleSize(32);
1509 case IsTupleLike::Error:
1513 case IsTupleLike::TupleLike:
1518 case IsTupleLike::NotTupleLike:
1527 << DD << !RD << DecompType;
1546 if (!getLangOpts().CXXExceptions)
1550 "Should only be called if types are otherwise the same.");
1561 NewType =
P->getPointeeType();
1574 if (CheckEquivalentExceptionSpec(
1594 if (FTD->isMemberSpecialization())
1600 if (Param->hasDefaultArg())
1611 if (!Param->hasDefaultArg() && !Param->isParameterPack() &&
1612 !(CurrentInstantiationScope &&
1613 CurrentInstantiationScope->isLocalPackExpansion(Param))) {
1614 if (Param->isInvalidDecl())
1616 else if (Param->getIdentifier())
1617 Diag(Param->getLocation(),
1618 diag::err_param_default_argument_missing_name)
1619 << Param->getIdentifier();
1621 Diag(Param->getLocation(),
1622 diag::err_param_default_argument_missing);
1630template <
typename... Ts>
1634 if (T->isDependentType())
1638 case Sema::CheckConstexprKind::Diagnose:
1640 std::forward<Ts>(DiagArgs)...);
1642 case Sema::CheckConstexprKind::CheckValid:
1643 return !T->isLiteralType(SemaRef.
Context);
1646 llvm_unreachable(
"unknown CheckConstexprKind");
1655 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
1659 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1663 SemaRef.
Diag(Loc, diag::note_constexpr_dtor_subobject)
1671 if (!Check(B.getBaseTypeLoc(), B.getType(),
nullptr))
1674 if (!Check(FD->getLocation(), FD->getType(), FD))
1684 unsigned ArgIndex = 0;
1687 e = FT->param_type_end();
1688 i != e; ++i, ++ArgIndex) {
1692 diag::err_constexpr_non_literal_param, ArgIndex + 1,
1705 diag::err_constexpr_non_literal_return,
1721 default: llvm_unreachable(
"Invalid tag kind for record diagnostic!");
1748 if (Kind == CheckConstexprKind::CheckValid)
1754 for (
const auto &I : RD->
vbases())
1755 Diag(I.getBeginLoc(), diag::note_constexpr_virtual_base_here)
1756 << I.getSourceRange();
1761 if (!isa<CXXConstructorDecl>(NewFD)) {
1766 const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD);
1767 if (Method && Method->isVirtual()) {
1769 if (Kind == CheckConstexprKind::Diagnose)
1770 Diag(Method->getLocation(), diag::warn_cxx17_compat_constexpr_virtual);
1772 if (Kind == CheckConstexprKind::CheckValid)
1775 Method = Method->getCanonicalDecl();
1776 Diag(Method->getLocation(), diag::err_constexpr_virtual);
1783 if (WrittenVirtual != Method)
1785 diag::note_overridden_virtual_function);
1795 if (
auto *Dtor = dyn_cast<CXXDestructorDecl>(NewFD)) {
1799 if (!Dtor->getParent()->defaultedDestructorIsConstexpr()) {
1800 if (Kind == CheckConstexprKind::CheckValid)
1813 "CheckConstexprFunctionDefinition called on function with no body");
1828 for (
const auto *DclIt : DS->
decls()) {
1829 switch (DclIt->getKind()) {
1830 case Decl::StaticAssert:
1832 case Decl::UsingShadow:
1833 case Decl::UsingDirective:
1834 case Decl::UnresolvedUsingTypename:
1835 case Decl::UnresolvedUsingValue:
1836 case Decl::UsingEnum:
1844 case Decl::TypeAlias: {
1848 if (TN->getUnderlyingType()->isVariablyModifiedType()) {
1850 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1851 TypeLoc TL = TN->getTypeSourceInfo()->getTypeLoc();
1862 case Decl::CXXRecord:
1864 if (cast<TagDecl>(DclIt)->isThisDeclarationADefinition()) {
1865 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1868 ? diag::warn_cxx11_compat_constexpr_type_definition
1869 : diag::ext_constexpr_type_definition)
1877 case Decl::EnumConstant:
1878 case Decl::IndirectField:
1885 case Decl::Decomposition: {
1891 if (VD->isThisDeclarationADefinition()) {
1892 if (VD->isStaticLocal()) {
1893 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1894 SemaRef.
Diag(VD->getLocation(),
1896 ? diag::warn_cxx20_compat_constexpr_var
1897 : diag::ext_constexpr_static_var)
1904 if (SemaRef.
LangOpts.CPlusPlus2b) {
1906 diag::warn_cxx20_compat_constexpr_var,
1907 isa<CXXConstructorDecl>(Dcl),
1910 SemaRef, Kind, VD->getLocation(), VD->getType(),
1911 diag::err_constexpr_local_var_non_literal_type,
1912 isa<CXXConstructorDecl>(Dcl))) {
1915 if (!VD->getType()->isDependentType() &&
1916 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
1917 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1921 ? diag::warn_cxx17_compat_constexpr_local_var_no_init
1922 : diag::ext_constexpr_local_var_no_init)
1930 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1931 SemaRef.
Diag(VD->getLocation(),
1933 ? diag::warn_cxx11_compat_constexpr_local_var
1934 : diag::ext_constexpr_local_var)
1942 case Decl::NamespaceAlias:
1943 case Decl::Function:
1951 if (Kind == Sema::CheckConstexprKind::Diagnose) {
1952 SemaRef.
Diag(DS->
getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
1978 llvm::SmallSet<Decl*, 16> &Inits,
1982 if (Kind == Sema::CheckConstexprKind::CheckValid &&
1986 if (Field->isInvalidDecl())
1989 if (Field->isUnnamedBitfield())
1995 if (Field->isAnonymousStructOrUnion() &&
1996 (Field->getType()->isUnionType()
1997 ? !Field->getType()->getAsCXXRecordDecl()->hasVariantMembers()
1998 : Field->getType()->getAsCXXRecordDecl()->isEmpty()))
2001 if (!Inits.count(Field)) {
2002 if (Kind == Sema::CheckConstexprKind::Diagnose) {
2006 ? diag::warn_cxx17_compat_constexpr_ctor_missing_init
2007 : diag::ext_constexpr_ctor_missing_init);
2010 SemaRef.
Diag(Field->getLocation(),
2011 diag::note_constexpr_ctor_missing_init);
2015 }
else if (Field->isAnonymousStructOrUnion()) {
2017 for (
auto *I : RD->
fields())
2020 if (!RD->
isUnion() || Inits.count(I))
2037 switch (S->getStmtClass()) {
2038 case Stmt::NullStmtClass:
2042 case Stmt::DeclStmtClass:
2052 case Stmt::ReturnStmtClass:
2054 if (isa<CXXConstructorDecl>(Dcl)) {
2057 Cxx1yLoc = S->getBeginLoc();
2061 ReturnStmts.push_back(S->getBeginLoc());
2064 case Stmt::AttributedStmtClass:
2068 SemaRef, Dcl, cast<AttributedStmt>(S)->getSubStmt(), ReturnStmts,
2069 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind);
2071 case Stmt::CompoundStmtClass: {
2074 Cxx1yLoc = S->getBeginLoc();
2077 for (
auto *BodyIt : CompStmt->
body()) {
2079 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2085 case Stmt::IfStmtClass: {
2088 Cxx1yLoc = S->getBeginLoc();
2092 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2096 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2101 case Stmt::WhileStmtClass:
2102 case Stmt::DoStmtClass:
2103 case Stmt::ForStmtClass:
2104 case Stmt::CXXForRangeStmtClass:
2105 case Stmt::ContinueStmtClass:
2111 Cxx1yLoc = S->getBeginLoc();
2112 for (
Stmt *SubStmt : S->children()) {
2115 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2120 case Stmt::SwitchStmtClass:
2121 case Stmt::CaseStmtClass:
2122 case Stmt::DefaultStmtClass:
2123 case Stmt::BreakStmtClass:
2127 Cxx1yLoc = S->getBeginLoc();
2128 for (
Stmt *SubStmt : S->children()) {
2131 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2136 case Stmt::LabelStmtClass:
2137 case Stmt::GotoStmtClass:
2139 Cxx2bLoc = S->getBeginLoc();
2140 for (
Stmt *SubStmt : S->children()) {
2143 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2148 case Stmt::GCCAsmStmtClass:
2149 case Stmt::MSAsmStmtClass:
2151 case Stmt::CXXTryStmtClass:
2153 Cxx2aLoc = S->getBeginLoc();
2154 for (
Stmt *SubStmt : S->children()) {
2157 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2162 case Stmt::CXXCatchStmtClass:
2166 SemaRef, Dcl, cast<CXXCatchStmt>(S)->getHandlerBlock(), ReturnStmts,
2167 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2177 Cxx1yLoc = S->getBeginLoc();
2181 if (Kind == Sema::CheckConstexprKind::Diagnose) {
2182 SemaRef.
Diag(S->getBeginLoc(), diag::err_constexpr_body_invalid_stmt)
2198 if (isa<CXXTryStmt>(Body)) {
2212 case Sema::CheckConstexprKind::CheckValid:
2217 case Sema::CheckConstexprKind::Diagnose:
2220 ? diag::ext_constexpr_function_try_block_cxx20
2221 : diag::warn_cxx17_compat_constexpr_function_try_block)
2236 Cxx1yLoc, Cxx2aLoc, Cxx2bLoc, Kind))
2240 if (Kind == Sema::CheckConstexprKind::CheckValid) {
2247 }
else if (Cxx2bLoc.
isValid()) {
2248 SemaRef.
Diag(Cxx2bLoc,
2250 ? diag::warn_cxx20_compat_constexpr_body_invalid_stmt
2251 : diag::ext_constexpr_body_invalid_stmt_cxx2b)
2253 }
else if (Cxx2aLoc.
isValid()) {
2254 SemaRef.
Diag(Cxx2aLoc,
2256 ? diag::warn_cxx17_compat_constexpr_body_invalid_stmt
2257 : diag::ext_constexpr_body_invalid_stmt_cxx20)
2259 }
else if (Cxx1yLoc.
isValid()) {
2260 SemaRef.
Diag(Cxx1yLoc,
2262 ? diag::warn_cxx11_compat_constexpr_body_invalid_stmt
2263 : diag::ext_constexpr_body_invalid_stmt)
2268 = dyn_cast<CXXConstructorDecl>(Dcl)) {
2277 if (Constructor->getNumCtorInitializers() == 0 &&
2279 if (Kind == Sema::CheckConstexprKind::Diagnose) {
2283 ? diag::warn_cxx17_compat_constexpr_union_ctor_no_init
2284 : diag::ext_constexpr_union_ctor_no_init);
2289 }
else if (!Constructor->isDependentContext() &&
2290 !Constructor->isDelegatingConstructor()) {
2291 assert(RD->
getNumVBases() == 0 &&
"constexpr ctor with virtual bases");
2295 bool AnyAnonStructUnionMembers =
false;
2296 unsigned Fields = 0;
2298 E = RD->
field_end(); I != E; ++I, ++Fields) {
2299 if (I->isAnonymousStructOrUnion()) {
2300 AnyAnonStructUnionMembers =
true;
2308 if (AnyAnonStructUnionMembers ||
2309 Constructor->getNumCtorInitializers() != RD->
getNumBases() + Fields) {
2313 llvm::SmallSet<Decl*, 16> Inits;
2314 for (
const auto *I: Constructor->inits()) {
2318 Inits.insert(ID->chain_begin(), ID->chain_end());
2321 bool Diagnosed =
false;
2322 for (
auto *I : RD->
fields())
2329 if (ReturnStmts.empty()) {
2338 case Sema::CheckConstexprKind::Diagnose:
2340 OK ? diag::warn_cxx11_compat_constexpr_body_no_return
2341 : diag::err_constexpr_body_no_return)
2347 case Sema::CheckConstexprKind::CheckValid:
2355 }
else if (ReturnStmts.size() > 1) {
2357 case Sema::CheckConstexprKind::Diagnose:
2361 ? diag::warn_cxx11_compat_constexpr_body_multiple_return
2362 : diag::ext_constexpr_body_multiple_return);
2363 for (
unsigned I = 0; I < ReturnStmts.size() - 1; ++I)
2364 SemaRef.
Diag(ReturnStmts[I],
2365 diag::note_constexpr_body_previous_return);
2368 case Sema::CheckConstexprKind::CheckValid:
2390 if (Kind == Sema::CheckConstexprKind::Diagnose &&
2393 diag::ext_constexpr_function_never_constant_expr)
2395 for (
size_t I = 0,
N = Diags.size(); I !=
N; ++I)
2396 SemaRef.
Diag(Diags[I].first, Diags[I].second);
2413 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2420 return dyn_cast_or_null<CXXRecordDecl>(DC);
2423 return dyn_cast_or_null<CXXRecordDecl>(CurContext);
2440 assert(getLangOpts().
CPlusPlus &&
"No class names in C!");
2442 if (!getLangOpts().SpellChecking)
2448 CurDecl = dyn_cast_or_null<CXXRecordDecl>(DC);
2450 CurDecl = dyn_cast_or_null<CXXRecordDecl>(CurContext);
2468 Class = Class->getCanonicalDecl();
2470 for (
const auto &I : Current->bases()) {
2479 if (
Base->getCanonicalDecl() == Class)
2482 Queue.push_back(
Base);
2488 Current = Queue.pop_back_val();
2505 if (getLangOpts().
HLSL && Class->getTagKind() ==
TTK_Class &&
2510 if (BaseType->containsErrors()) {
2516 if (Class->isUnion()) {
2517 Diag(Class->getLocation(), diag::err_base_clause_on_union)
2524 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
2531 if (BaseType->isDependentType()) {
2535 if (
CXXRecordDecl *BaseDecl = BaseType->getAsCXXRecordDecl()) {
2536 if (BaseDecl->getCanonicalDecl() == Class->getCanonicalDecl() ||
2537 ((BaseDecl = BaseDecl->getDefinition()) &&
2539 Diag(BaseLoc, diag::err_circular_inheritance)
2542 if (BaseDecl->getCanonicalDecl() != Class->getCanonicalDecl())
2543 Diag(BaseDecl->getLocation(), diag::note_previous_decl)
2556 if (!Class->getTypeForDecl()->isDependentType())
2557 Class->setInvalidDecl();
2560 Access, TInfo, EllipsisLoc);
2564 if (!BaseType->isRecordType()) {
2565 Diag(BaseLoc, diag::err_base_must_be_class) << SpecifierRange;
2571 if (BaseType->isUnionType()) {
2572 Diag(BaseLoc, diag::err_union_as_base_class) << SpecifierRange;
2579 if (
auto *BaseTemplate = dyn_cast_or_null<ClassTemplateSpecializationDecl>(
2580 BaseType->getAsCXXRecordDecl())) {
2581 propagateDLLAttrToBaseClassTemplate(Class, ClassAttr, BaseTemplate,
2590 if (RequireCompleteType(BaseLoc, BaseType,
2591 diag::err_incomplete_base_class, SpecifierRange)) {
2592 Class->setInvalidDecl();
2598 assert(BaseDecl &&
"Record type has no declaration");
2600 assert(BaseDecl &&
"Base type is not incomplete, but has no definition");
2602 assert(CXXBaseDecl &&
"Base type is not a C++ type");
2607 const auto *BaseCSA = CXXBaseDecl->
getAttr<CodeSegAttr>();
2608 const auto *DerivedCSA = Class->getAttr<CodeSegAttr>();
2609 if ((DerivedCSA || BaseCSA) &&
2610 (!BaseCSA || !DerivedCSA || BaseCSA->getName() != DerivedCSA->getName())) {
2611 Diag(Class->getLocation(), diag::err_mismatched_code_seg_base);
2612 Diag(CXXBaseDecl->
getLocation(), diag::note_base_class_specified_here)
2624 Diag(BaseLoc, diag::err_base_class_has_flexible_array_member)
2632 if (FinalAttr *FA = CXXBaseDecl->
getAttr<FinalAttr>()) {
2633 Diag(BaseLoc, diag::err_class_marked_final_used_as_base)
2635 << FA->isSpelledAsSealed();
2642 Class->setInvalidDecl();
2647 Access, TInfo, EllipsisLoc);
2663 AdjustDeclIfTemplate(classdecl);
2669 Class->setIsParsingBaseSpecifiers();
2674 if (AL.isInvalid() || AL.getKind() == ParsedAttr::IgnoredAttribute)
2676 Diag(AL.getLoc(), AL.getKind() == ParsedAttr::UnknownAttribute
2677 ? (
unsigned)diag::warn_unknown_attribute_ignored
2678 : (
unsigned)diag::err_base_specifier_attribute)
2679 << AL << AL.getRange();
2683 GetTypeFromParser(basetype, &TInfo);
2686 DiagnoseUnexpandedParameterPack(SpecifierRange.
getBegin(), TInfo,
2695 Class->setInvalidDecl();
2712 auto Decl = Rec->getAsCXXRecordDecl();
2715 for (
const auto &BaseSpec :
Decl->bases()) {
2718 if (Set.insert(
Base).second)
2736 std::map<QualType, CXXBaseSpecifier*, QualTypeOrdering> KnownBaseTypes;
2743 unsigned NumGoodBases = 0;
2745 for (
unsigned idx = 0; idx < Bases.size(); ++idx) {
2755 Diag(Bases[idx]->getBeginLoc(), diag::err_duplicate_base_class)
2756 << KnownBase->
getType() << Bases[idx]->getSourceRange();
2765 KnownBase = Bases[idx];
2766 Bases[NumGoodBases++] = Bases[idx];
2771 if (Bases.size() > 1)
2776 if (Class->isInterface() &&
2787 Class->addAttr(WeakAttr::CreateImplicit(Context));
2793 Class->setBases(Bases.data(), NumGoodBases);
2796 for (
unsigned idx = 0; idx < NumGoodBases; ++idx) {
2798 QualType BaseType = Bases[idx]->getType();
2802 if (BaseType->isDependentType())
2808 if (IndirectBaseTypes.count(CanonicalBase)) {
2812 = Class->isDerivedFrom(CanonicalBase->getAsCXXRecordDecl(), Paths);
2816 if (Paths.isAmbiguous(CanonicalBase))
2817 Diag(Bases[idx]->getBeginLoc(), diag::warn_inaccessible_base_class)
2818 << BaseType << getAmbiguousPathsDisplayString(Paths)
2819 << Bases[idx]->getSourceRange();
2821 assert(Bases[idx]->isVirtual());
2837 if (!ClassDecl || Bases.empty())
2840 AdjustDeclIfTemplate(ClassDecl);
2841 AttachBaseSpecifiers(cast<CXXRecordDecl>(ClassDecl), Bases);
2865 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2886 if (!isCompleteType(Loc, Derived) && !DerivedRD->
isBeingDefined())
2898 for (
unsigned I = Path.size(); I != 0; --I) {
2899 if (Path[I - 1].
Base->isVirtual()) {
2906 for (
unsigned I = Start, E = Path.size(); I != E; ++I)
2913 assert(BasePathArray.empty() &&
"Base path array must be empty!");
2914 assert(Paths.isRecordingPaths() &&
"Must record paths!");
2915 return ::BuildBasePathArray(Paths.front(), BasePathArray);
2931 unsigned InaccessibleBaseID,
2932 unsigned AmbiguousBaseConvID,
2936 bool IgnoreAccess) {
2943 bool DerivationOkay = IsDerivedFrom(Loc, Derived,
Base, Paths);
2944 if (!DerivationOkay)
2949 Path = &Paths.front();
2954 if (!Path && getLangOpts().MSVCCompat) {
2956 if (PossiblePath.size() == 1) {
2957 Path = &PossiblePath;
2958 if (AmbiguousBaseConvID)
2959 Diag(Loc, diag::ext_ms_ambiguous_direct_base)
2960 <<
Base << Derived << Range;
2967 if (!IgnoreAccess) {
2970 CheckBaseClassAccess(Loc,
Base, Derived, *Path, InaccessibleBaseID)) {
2986 if (AmbiguousBaseConvID) {
2994 Paths.setRecordingPaths(
true);
2995 bool StillOkay = IsDerivedFrom(Loc, Derived,
Base, Paths);
2996 assert(StillOkay &&
"Can only be used with a derived-to-base conversion");
3003 std::string PathDisplayStr = getAmbiguousPathsDisplayString(Paths);
3005 Diag(Loc, AmbiguousBaseConvID)
3006 << Derived <<
Base << PathDisplayStr << Range << Name;
3015 bool IgnoreAccess) {
3016 return CheckDerivedToBaseConversion(
3017 Derived,
Base, diag::err_upcast_to_inaccessible_base,
3018 diag::err_ambiguous_derived_to_base_conv, Loc, Range,
DeclarationName(),
3019 BasePath, IgnoreAccess);
3036 std::string PathDisplayStr;
3037 std::set<unsigned> DisplayedPaths;
3039 Path != Paths.end(); ++Path) {
3040 if (DisplayedPaths.insert(Path->back().SubobjectNumber).second) {
3043 PathDisplayStr +=
"\n ";
3045 for (CXXBasePath::const_iterator Element = Path->begin();
3046 Element != Path->end(); ++Element)
3047 PathDisplayStr +=
" -> " + Element->Base->getType().getAsString();
3051 return PathDisplayStr;
3062 assert(Access !=
AS_none &&
"Invalid kind for syntactic access specifier!");
3065 CurContext->addHiddenDecl(ASDecl);
3066 return ProcessAccessDeclAttributeList(ASDecl, Attrs);
3090 FindHiddenVirtualMethods(MD, OverloadedMethods);
3092 if (!OverloadedMethods.empty()) {
3093 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3094 Diag(OA->getLocation(),
3095 diag::override_keyword_hides_virtual_member_function)
3096 <<
"override" << (OverloadedMethods.size() > 1);
3097 }
else if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3098 Diag(FA->getLocation(),
3099 diag::override_keyword_hides_virtual_member_function)
3100 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3101 << (OverloadedMethods.size() > 1);
3103 NoteHiddenVirtualMethods(MD, OverloadedMethods);
3112 if (OverrideAttr *OA = D->
getAttr<OverrideAttr>()) {
3113 Diag(OA->getLocation(),
3114 diag::override_keyword_only_allowed_on_virtual_member_functions)
3118 if (FinalAttr *FA = D->
getAttr<FinalAttr>()) {
3119 Diag(FA->getLocation(),
3120 diag::override_keyword_only_allowed_on_virtual_member_functions)
3121 << (FA->isSpelledAsSealed() ?
"sealed" :
"final")
3133 if (MD->
hasAttr<OverrideAttr>() && !HasOverriddenMethods)
3134 Diag(MD->
getLocation(), diag::err_function_marked_override_not_overriding)
3147 if (getSourceManager().isMacroArgExpansion(Loc))
3148 SpellingLoc = getSourceManager().getImmediateExpansionRange(Loc).getBegin();
3149 SpellingLoc = getSourceManager().getSpellingLoc(SpellingLoc);
3150 if (SpellingLoc.
isValid() && getSourceManager().isInSystemHeader(SpellingLoc))
3154 auto EmitDiag = [&](
unsigned DiagInconsistent,
unsigned DiagSuggest) {
3156 Inconsistent && !Diags.isIgnored(DiagInconsistent, MD->
getLocation())
3163 if (isa<CXXDestructorDecl>(MD))
3165 diag::warn_inconsistent_destructor_marked_not_override_overriding,
3166 diag::warn_suggest_destructor_marked_not_override_overriding);
3168 EmitDiag(diag::warn_inconsistent_function_marked_not_override_overriding,
3169 diag::warn_suggest_function_marked_not_override_overriding);
3178 FinalAttr *FA = Old->
getAttr<FinalAttr>();
3184 << FA->isSpelledAsSealed();
3193 return !RD->isCompleteDefinition() ||
3194 !RD->hasTrivialDefaultConstructor() ||
3195 !RD->hasTrivialDestructor();
3201 llvm::find_if(list, [](
const ParsedAttr &AL) {
3204 if (Itr != list.
end())
3214 if (Diags.isIgnored(diag::warn_shadow_field, Loc))
3218 std::map<CXXRecordDecl*, NamedDecl*> Bases;
3221 const auto Base = Specifier->getType()->getAsCXXRecordDecl();
3223 if (Bases.find(
Base) != Bases.end())
3225 for (
const auto Field :
Base->lookup(FieldName)) {
3226 if ((isa<FieldDecl>(Field) || isa<IndirectFieldDecl>(Field)) &&
3229 assert(Bases.find(
Base) == Bases.end());
3242 for (
const auto &
P : Paths) {
3243 auto Base =
P.back().Base->getType()->getAsCXXRecordDecl();
3244 auto It = Bases.find(
Base);
3246 if (It == Bases.end())
3248 auto BaseField = It->second;
3249 assert(BaseField->getAccess() !=
AS_private);
3252 Diag(Loc, diag::warn_shadow_field)
3253 << FieldName << RD <<
Base << DeclIsField;
3254 Diag(BaseField->getLocation(), diag::note_shadow_field);
3279 Expr *BitWidth =
static_cast<Expr*
>(BW);
3281 assert(isa<CXXRecordDecl>(CurContext));
3288 if (cast<CXXRecordDecl>(CurContext)->isInterface()) {
3292 unsigned InvalidDecl;
3293 bool ShowDeclName =
true;
3303 else switch (Name.getNameKind()) {
3306 ShowDeclName =
false;
3311 ShowDeclName =
false;
3326 Diag(Loc, diag::err_invalid_member_in_interface)
3327 << (InvalidDecl-1) << Name;
3329 Diag(Loc, diag::err_invalid_member_in_interface)
3330 << (InvalidDecl-1) <<
"";
3356 diag::err_storageclass_invalid_for_member);
3376 const char *PrevSpec;
3381 assert(!Failed &&
"Making a constexpr member const shouldn't fail");
3385 const char *PrevSpec;
3391 "This is the only DeclSpec that should fail to be applied");
3395 isInstField =
false;
3405 if (!Name.isIdentifier()) {
3406 Diag(Loc, diag::err_bad_variable_name)
3415 if (TemplateParameterLists.size()) {
3417 if (TemplateParams->
size()) {
3426 diag::err_template_member_noparams)
3450 if (
DeclContext *DC = computeDeclContext(SS,
false))
3453 UnqualifiedIdKind::IK_TemplateId);
3461 if (MSPropertyAttr) {
3462 Member = HandleMSProperty(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3463 BitWidth, InitStyle, AS, *MSPropertyAttr);
3466 isInstField =
false;
3468 Member = HandleField(S, cast<CXXRecordDecl>(CurContext), Loc, D,
3469 BitWidth, InitStyle, AS);
3474 CheckShadowInheritedFields(Loc, Name, cast<CXXRecordDecl>(CurContext));
3476 Member = HandleDeclarator(S, D, TemplateParameterLists);
3482 if (
Member->isInvalidDecl()) {
3484 }
else if (isa<VarDecl>(
Member) || isa<VarTemplateDecl>(
Member)) {
3487 Diag(Loc, diag::err_static_not_bitfield)
3489 }
else if (isa<TypedefDecl>(
Member)) {
3491 Diag(Loc, diag::err_typedef_not_bitfield)
3496 Diag(Loc, diag::err_not_integral_type_bitfield)
3497 << Name << cast<ValueDecl>(
Member)->getType()
3502 Member->setInvalidDecl();
3507 NonTemplateMember = FunTmpl->getTemplatedDecl();
3509 NonTemplateMember = VarTmpl->getTemplatedDecl();
3515 if (NonTemplateMember !=
Member)
3521 if (
auto *DG = dyn_cast<CXXDeductionGuideDecl>(NonTemplateMember)) {
3522 auto *TD = DG->getDeducedTemplate();
3525 if (AS != TD->getAccess() &&
3526 TD->getDeclContext()->getRedeclContext()->Equals(
3527 DG->getDeclContext()->getRedeclContext())) {
3528 Diag(DG->getBeginLoc(), diag::err_deduction_guide_wrong_access);
3529 Diag(TD->getBeginLoc(), diag::note_deduction_guide_template_access)
3532 for (
const auto *D : cast<CXXRecordDecl>(CurContext)->decls()) {
3533 if (
const auto *AccessSpec = dyn_cast<AccessSpecDecl>(D))
3534 LastAccessSpec = AccessSpec;
3536 assert(LastAccessSpec &&
"differing access with no access specifier");
3537 Diag(LastAccessSpec->
getBeginLoc(), diag::note_deduction_guide_access)
3547 Member->addAttr(FinalAttr::Create(
3557 CheckOverrideControl(
Member);
3559 assert((Name || isInstField) &&
"No identifier for non-field ?");
3563 FieldCollector->Add(FD);
3565 if (!Diags.isIgnored(diag::warn_unused_private_field, FD->
getLocation())) {
3573 UnusedPrivateFields.insert(FD);
3581 class UninitializedFieldVisitor
3586 llvm::SmallPtrSetImpl<ValueDecl*> &Decls;
3589 llvm::SmallPtrSetImpl<QualType> &BaseClasses;
3604 UninitializedFieldVisitor(
Sema &S,
3605 llvm::SmallPtrSetImpl<ValueDecl*> &Decls,
3606 llvm::SmallPtrSetImpl<QualType> &BaseClasses)
3607 : Inherited(S.Context), S(S), Decls(Decls), BaseClasses(BaseClasses),
3608 Constructor(nullptr), InitList(
false), InitListFieldDecl(nullptr) {}
3611 bool IsInitListMemberExprInitialized(
MemberExpr *ME,
3612 bool CheckReferenceOnly) {
3614 bool ReferenceField =
false;
3619 Fields.push_back(FD);
3621 ReferenceField =
true;
3627 if (CheckReferenceOnly && !ReferenceField)
3633 for (
const FieldDecl *FD : llvm::drop_begin(llvm::reverse(Fields)))
3636 for (
auto UsedIter = UsedFieldIndex.begin(),
3637 UsedEnd = UsedFieldIndex.end(),
3638 OrigIter = InitFieldIndex.begin(),
3639 OrigEnd = InitFieldIndex.end();
3640 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
3641 if (*UsedIter < *OrigIter)
3643 if (*UsedIter > *OrigIter)
3650 void HandleMemberExpr(
MemberExpr *ME,
bool CheckReferenceOnly,
3663 dyn_cast<MemberExpr>(
Base->IgnoreParenImpCasts())) {
3665 if (isa<VarDecl>(SubME->getMemberDecl()))
3668 if (
FieldDecl *FD = dyn_cast<FieldDecl>(SubME->getMemberDecl()))
3673 AllPODFields =
false;
3675 Base = SubME->getBase();
3678 if (!isa<CXXThisExpr>(
Base->IgnoreParenImpCasts())) {
3683 if (AddressOf && AllPODFields)
3689 while (isa<ImplicitCastExpr>(BaseCast->getSubExpr())) {
3693 if (BaseCast->getCastKind() == CK_UncheckedDerivedToBase) {
3695 if (T->isPointerType() &&
3696 BaseClasses.count(T->getPointeeType())) {
3698 << T->getPointeeType() << FoundVD;
3703 if (!Decls.count(FoundVD))
3708 if (InitList && !AddressOf && FoundVD == InitListFieldDecl) {
3710 if (IsInitListMemberExprInitialized(ME, CheckReferenceOnly)) {
3715 if (CheckReferenceOnly && !IsReference)
3719 unsigned diag = IsReference
3720 ? diag::warn_reference_field_is_uninit
3721 : diag::warn_field_is_uninit;
3725 diag::note_uninit_in_this_constructor)
3730 void HandleValue(
Expr *E,
bool AddressOf) {
3733 if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3734 HandleMemberExpr(ME,
false ,
3740 Visit(CO->getCond());
3741 HandleValue(CO->getTrueExpr(), AddressOf);
3742 HandleValue(CO->getFalseExpr(), AddressOf);
3747 dyn_cast<BinaryConditionalOperator>(E)) {
3748 Visit(BCO->getCond());
3749 HandleValue(BCO->getFalseExpr(), AddressOf);
3754 HandleValue(OVE->getSourceExpr(), AddressOf);
3759 switch (BO->getOpcode()) {
3764 HandleValue(BO->getLHS(), AddressOf);
3765 Visit(BO->getRHS());
3768 Visit(BO->getLHS());
3769 HandleValue(BO->getRHS(), AddressOf);
3778 InitFieldIndex.push_back(0);
3779 for (
auto Child : ILE->
children()) {
3780 if (
InitListExpr *SubList = dyn_cast<InitListExpr>(Child)) {
3781 CheckInitListExpr(SubList);
3785 ++InitFieldIndex.back();
3787 InitFieldIndex.pop_back();
3796 DeclsToRemove.clear();
3803 InitListFieldDecl =
Field;
3804 InitFieldIndex.clear();
3805 CheckInitListExpr(ILE);
3814 BaseClasses.erase(BaseClass->getCanonicalTypeInternal());
3819 HandleMemberExpr(ME,
true ,
false );
3828 Inherited::VisitImplicitCastExpr(E);
3834 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
3838 if (ICE->getCastKind() == CK_NoOp)
3839 ArgExpr = ICE->getSubExpr();
3840 HandleValue(ArgExpr,
false );
3843 Inherited::VisitCXXConstructExpr(E);
3848 if (isa<MemberExpr>(Callee)) {
3849 HandleValue(Callee,
false );
3855 Inherited::VisitCXXMemberCallExpr(E);
3861 HandleValue(E->
getArg(0),
false);
3865 Inherited::VisitCallExpr(E);
3871 if (isa<UnresolvedLookupExpr>(Callee))
3872 return Inherited::VisitCXXOperatorCallExpr(E);
3876 HandleValue(Arg->IgnoreParenImpCasts(),
false );
3886 DeclsToRemove.push_back(FD);
3889 HandleValue(E->
getLHS(),
false );
3894 Inherited::VisitBinaryOperator(E);
3904 HandleValue(ME->
getBase(),
true );
3909 Inherited::VisitUnaryOperator(E);
3919 static void DiagnoseUninitializedFields(
3939 for (
auto *I : RD->
decls()) {
3940 if (
auto *FD = dyn_cast<FieldDecl>(I)) {
3941 UninitializedFields.insert(FD);
3942 }
else if (
auto *IFD = dyn_cast<IndirectFieldDecl>(I)) {
3943 UninitializedFields.insert(IFD->getAnonField());
3948 for (
auto I : RD->
bases())
3949 UninitializedBaseClasses.insert(I.getType().getCanonicalType());
3951 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3954 UninitializedFieldVisitor UninitializedChecker(SemaRef,
3955 UninitializedFields,
3956 UninitializedBaseClasses);
3958 for (
const auto *FieldInit :
Constructor->inits()) {
3959 if (UninitializedFields.empty() && UninitializedBaseClasses.empty())
3962 Expr *InitExpr = FieldInit->getInit();
3967 dyn_cast<CXXDefaultInitExpr>(InitExpr)) {
3968 InitExpr =
Default->getExpr();
3972 UninitializedChecker.CheckInitializer(InitExpr, Constructor,
3973 FieldInit->getAnyMember(),
3974 FieldInit->getBaseClass());
3976 UninitializedChecker.CheckInitializer(InitExpr,
nullptr,
3977 FieldInit->getAnyMember(),
3978 FieldInit->getBaseClass());
3990 PushFunctionScope();
4002 if (ParamDecl->getDeclName())
4003 PushOnScopeChains(ParamDecl, S,
false);
4008 return ActOnRequiresClause(ConstraintExpr);
4015 ConstraintExpr = CorrectDelayedTyposInExpr(ConstraintExpr);
4019 if (DiagnoseUnexpandedParameterPack(ConstraintExpr.
get(),
4020 UPPC_RequiresClause))
4023 return ConstraintExpr;
4033 PopFunctionScopeInfo(
nullptr, D);
4037 "must set init style when field is created");
4046 if (DiagnoseUnexpandedParameterPack(InitExpr, UPPC_Initializer)) {
4063 Init = Seq.
Perform(*
this, Entity, Kind, InitExpr);
4064 if (Init.isInvalid()) {
4073 Init = ActOnFinishFullExpr(Init.get(), InitLoc,
false);
4074 if (Init.isInvalid()) {
4079 InitExpr = Init.get();
4093 DirectBaseSpec =
nullptr;
4094 for (
const auto &
Base : ClassDecl->
bases()) {
4098 DirectBaseSpec = &
Base;
4106 VirtualBaseSpec =
nullptr;
4107 if (!DirectBaseSpec || !DirectBaseSpec->
isVirtual()) {
4116 Path != Paths.end(); ++Path) {
4117 if (Path->back().Base->isVirtual()) {
4118 VirtualBaseSpec = Path->back().Base;
4125 return DirectBaseSpec || VirtualBaseSpec;
4139 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
4140 DS, IdLoc, InitList,
4158 return BuildMemInitializer(ConstructorD, S, SS, MemberOrBase, TemplateTypeTy,
4159 DS, IdLoc, List, EllipsisLoc);
4168 explicit MemInitializerValidatorCCC(
CXXRecordDecl *ClassDecl)
4169 : ClassDecl(ClassDecl) {}
4171 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4174 return Member->getDeclContext()->getRedeclContext()->Equals(ClassDecl);
4180 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
4181 return std::make_unique<MemInitializerValidatorCCC>(*
this);
4196 for (
auto *D : ClassDecl->
lookup(MemberOrBase))
4197 if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D))
4213 ExprResult Res = CorrectDelayedTyposInExpr(Init,
nullptr,
4222 AdjustDeclIfTemplate(ConstructorD);
4225 = dyn_cast<CXXConstructorDecl>(ConstructorD);
4249 ClassDecl, SS, TemplateTypeTy, MemberOrBase)) {
4251 Diag(EllipsisLoc, diag::err_pack_expansion_member_init)
4253 <<
SourceRange(IdLoc, Init->getSourceRange().getEnd());
4255 return BuildMemberInitializer(
Member, Init, IdLoc);
4261 if (TemplateTypeTy) {
4262 BaseType = GetTypeFromParser(TemplateTypeTy, &TInfo);
4263 if (BaseType.isNull())
4271 LookupResult R(*
this, MemberOrBase, IdLoc, LookupOrdinaryName);
4272 LookupParsedName(R, S, &SS);
4281 if (SS.
isSet() && isDependentScopeSpecifier(SS)) {
4282 bool NotUnknownSpecialization =
false;
4284 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(DC))
4285 NotUnknownSpecialization = !Record->hasAnyDependentBases();
4287 if (!NotUnknownSpecialization) {
4292 *MemberOrBase, IdLoc);
4293 if (BaseType.isNull())
4310 if (getLangOpts().MSVCCompat && !getLangOpts().
CPlusPlus20) {
4312 if (UnqualifiedBase) {
4313 Diag(IdLoc, diag::ext_unqualified_base_class)
4314 <<
SourceRange(IdLoc, Init->getSourceRange().getEnd());
4315 BaseType = UnqualifiedBase->getInjectedClassNameSpecialization();
4321 MemInitializerValidatorCCC CCC(ClassDecl);
4322 if (R.
empty() && BaseType.isNull() &&
4324 CCC, CTK_ErrorRecovery, ClassDecl))) {
4330 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4331 << MemberOrBase <<
true);
4332 return BuildMemberInitializer(
Member, Init, IdLoc);
4338 DirectBaseSpec, VirtualBaseSpec)) {
4343 PDiag(diag::err_mem_init_not_member_or_class_suggest)
4344 << MemberOrBase <<
false,
4357 if (!TyD && BaseType.isNull()) {
4358 Diag(IdLoc, diag::err_mem_init_not_member_or_class)
4359 << MemberOrBase <<
SourceRange(IdLoc,Init->getSourceRange().getEnd());
4364 if (BaseType.isNull()) {
4366 MarkAnyDeclReferenced(TyD->
getLocation(), TyD,
false);
4382 return BuildBaseInitializer(BaseType, TInfo, Init, ClassDecl, EllipsisLoc);
4390 assert((DirectMember || IndirectMember) &&
4391 "Member must be a FieldDecl or IndirectFieldDecl");
4393 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4396 if (
Member->isInvalidDecl())
4400 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4401 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4402 }
else if (
InitListExpr *InitList = dyn_cast<InitListExpr>(Init)) {
4403 Args =
MultiExprArg(InitList->getInits(), InitList->getNumInits());
4411 if (
Member->getType()->isDependentType() || Init->isTypeDependent()) {
4414 DiscardCleanupsInEvaluationContext();
4416 bool InitList =
false;
4417 if (isa<InitListExpr>(Init)) {
4429 IdLoc, Init->getBeginLoc(), Init->getEndLoc())
4440 MemberInit = ActOnFinishFullExpr(MemberInit.
get(), InitRange.
getBegin(),
4447 Init = CreateRecoveryExpr(InitRange.
getBegin(), InitRange.
getEnd(), Args,
4453 Init = MemberInit.
get();
4472 if (!LangOpts.CPlusPlus11)
4473 return Diag(NameLoc, diag::err_delegating_ctor)
4475 Diag(NameLoc, diag::warn_cxx98_compat_delegating_ctor);
4477 bool InitList =
true;
4479 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4481 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4490 NameLoc, Init->getBeginLoc(), Init->getEndLoc())
4498 cast<CXXConstructExpr>(DelegationInit.
get())->getConstructor()) &&
4499 "Delegating constructor with no target?");
4504 DelegationInit = ActOnFinishFullExpr(
4505 DelegationInit.
get(), InitRange.
getBegin(),
false);
4510 CreateRecoveryExpr(InitRange.
getBegin(), InitRange.
getEnd(), Args,
4522 if (CurContext->isDependentContext())
4523 DelegationInit = Init;
4538 if (!BaseType->isDependentType() && !BaseType->isRecordType())
4539 return Diag(BaseLoc, diag::err_base_init_does_not_name_class)
4552 bool Dependent = CurContext->isDependentContext() &&
4553 (BaseType->isDependentType() || Init->isTypeDependent());
4558 if (!BaseType->containsUnexpandedParameterPack()) {
4559 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
4566 if (DiagnoseUnexpandedParameterPack(BaseLoc, BaseTInfo, UPPC_Initializer))
4569 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer))
4579 return BuildDelegatingInitializer(BaseTInfo, Init, ClassDecl);
4588 if (!DirectBaseSpec && !VirtualBaseSpec) {
4597 return Diag(BaseLoc, diag::err_not_direct_base_or_virtual)
4604 DiscardCleanupsInEvaluationContext();
4609 InitRange.
getEnd(), EllipsisLoc);
4616 if (DirectBaseSpec && VirtualBaseSpec)
4617 return Diag(BaseLoc, diag::err_base_init_direct_and_virtual)
4622 BaseSpec = VirtualBaseSpec;
4625 bool InitList =
true;
4627 if (
ParenListExpr *ParenList = dyn_cast<ParenListExpr>(Init)) {
4629 Args =
MultiExprArg(ParenList->getExprs(), ParenList->getNumExprs());
4644 BaseInit = ActOnFinishFullExpr(BaseInit.
get(), InitRange.
getBegin(),
4649 BaseInit = CreateRecoveryExpr(InitRange.
getBegin(), InitRange.
getEnd(),
4661 if (CurContext->isDependentContext())
4669 InitRange.
getEnd(), EllipsisLoc);
4674 if (T.isNull()) T = E->
getType();
4679 TargetType, ExprLoc);
4699 bool IsInheritedVirtualBase,
4703 IsInheritedVirtualBase);
4707 switch (ImplicitInitKind) {
4713 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, None);
4719 bool Moving = ImplicitInitKind ==
IIK_Move;
4720 ParmVarDecl *Param = Constructor->getParamDecl(0);
4721 QualType ParamType = Param->getType().getNonReferenceType();
4726 Constructor->getLocation(), ParamType,
4741 BasePath.push_back(BaseSpec);
4743 CK_UncheckedDerivedToBase,
4751 BaseInit = InitSeq.
Perform(SemaRef, InitEntity, InitKind, CopyCtorArg);
4783 if (Field->isInvalidDecl())
4789 bool Moving = ImplicitInitKind ==
IIK_Move;
4790 ParmVarDecl *Param = Constructor->getParamDecl(0);
4791 QualType ParamType = Param->getType().getNonReferenceType();
4794 if (Field->isZeroLengthBitField(SemaRef.
Context))
4797 Expr *MemberExprBase =
4810 LookupResult MemberLookup(SemaRef, Field->getDeclName(), Loc,
4812 MemberLookup.
addDecl(Indirect ? cast<ValueDecl>(Indirect)
4848 InitSeq.Perform(SemaRef, Entity, InitKind,
MultiExprArg(&CtorArgE, 1));
4863 "Unhandled implicit init kind!");
4879 InitSeq.
Perform(SemaRef, InitEntity, InitKind, None);
4899 if (!Field->getParent()->isUnion()) {
4901 SemaRef.
Diag(Constructor->getLocation(),
4902 diag::err_uninitialized_member_in_ctor)
4903 << (
int)Constructor->isImplicit()
4905 << 0 << Field->getDeclName();
4906 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
4911 SemaRef.
Diag(Constructor->getLocation(),
4912 diag::err_uninitialized_member_in_ctor)
4913 << (
int)Constructor->isImplicit()
4915 << 1 << Field->getDeclName();
4916 SemaRef.
Diag(Field->getLocation(), diag::note_declared_at);
4933 CXXMemberInit =
nullptr;
4938struct BaseAndFieldInfo {
4941 bool AnyErrorsInInits;
4943 llvm::DenseMap<const void *, CXXCtorInitializer*> AllBaseFields;
4945 llvm::DenseMap<TagDecl*, FieldDecl*> ActiveUnionMember;
4948 : S(S), Ctor(Ctor), AnyErrorsInInits(ErrorsInInits) {
4960 bool isImplicitCopyOrMove()
const {
4971 llvm_unreachable(
"Invalid ImplicitInitializerKind!");
4975 AllToInit.push_back(Init);
4978 if (Init->getInit()->HasSideEffects(S.
Context))
4984 bool isInactiveUnionMember(
FieldDecl *Field) {
4990 ActiveUnionMember.lookup(
Record->getCanonicalDecl()))
4991 return Active !=
Field->getCanonicalDecl();
4994 if (isImplicitCopyOrMove())
4999 if (
Field->hasInClassInitializer())
5003 if (!
Field->isAnonymousStructOrUnion())
5012 bool isWithinInactiveUnionMember(
FieldDecl *Field,
5015 return isInactiveUnionMember(Field);
5017 for (
auto *
C : Indirect->
chain()) {
5019 if (Field && isInactiveUnionMember(Field))
5030 if (T->isIncompleteArrayType())
5034 if (!ArrayT->getSize())
5037 T = ArrayT->getElementType();
5046 if (Field->isInvalidDecl())
5051 Info.AllBaseFields.lookup(Field->getCanonicalDecl()))
5052 return Info.addFieldInitializer(Init);
5066 if (Info.isWithinInactiveUnionMember(Field, Indirect))
5069 if (Field->hasInClassInitializer() && !Info.isImplicitCopyOrMove()) {
5087 return Info.addFieldInitializer(Init);
5097 if (Info.AnyErrorsInInits)
5108 return Info.addFieldInitializer(Init);
5115 Constructor->setNumCtorInitializers(1);
5119 Constructor->setCtorInitializers(initializer);
5122 MarkFunctionReferenced(
Initializer->getSourceLocation(), Dtor);
5123 DiagnoseUseOfDecl(Dtor,
Initializer->getSourceLocation());
5126 DelegatingCtorDecls.push_back(Constructor);
5128 DiagnoseUninitializedFields(*
this, Constructor);
5135 if (Constructor->isDependentContext()) {
5138 if (!Initializers.empty()) {
5139 Constructor->setNumCtorInitializers(Initializers.size());
5142 memcpy(baseOrMemberInitializers, Initializers.data(),
5144 Constructor->setCtorInitializers(baseOrMemberInitializers);
5149 Constructor->setInvalidDecl();
5154 BaseAndFieldInfo Info(*
this, Constructor, AnyErrors);
5158 CXXRecordDecl *ClassDecl = Constructor->getParent()->getDefinition();
5162 bool HadError =
false;
5164 for (
unsigned i = 0; i < Initializers.size(); i++) {
5167 if (
Member->isBaseInitializer())
5170 Info.AllBaseFields[
Member->getAnyMember()->getCanonicalDecl()] =
Member;
5173 for (
auto *
C : F->chain()) {
5176 Info.ActiveUnionMember.insert(std::make_pair(
5181 Info.ActiveUnionMember.insert(std::make_pair(
5189 for (
auto &I : ClassDecl->
bases()) {
5191 DirectVBases.insert(&I);
5195 for (
auto &VBase : ClassDecl->
vbases()) {
5197 = Info.AllBaseFields.lookup(VBase.getType()->getAs<
RecordType>())) {
5205 Diag(
Value->getSourceLocation(), diag::warn_abstract_vbase_init_ignored)
5206 << VBase.getType() << ClassDecl;
5207 DiagnoseAbstractType(ClassDecl);
5210 Info.AllToInit.push_back(
Value);
5211 }
else if (!AnyErrors && !ClassDecl->
isAbstract()) {
5216 bool IsInheritedVirtualBase = !DirectVBases.count(&VBase);
5219 &VBase, IsInheritedVirtualBase,
5225 Info.AllToInit.push_back(CXXBaseInit);
5232 if (
Base.isVirtual())
5236 = Info.AllBaseFields.lookup(
Base.getType()->getAs<
RecordType>())) {
5237 Info.AllToInit.push_back(
Value);
5238 }
else if (!AnyErrors) {
5247 Info.AllToInit.push_back(CXXBaseInit);
5252 for (
auto *Mem : ClassDecl->
decls()) {
5253 if (
auto *F = dyn_cast<FieldDecl>(Mem)) {
5258 if (F->isUnnamedBitfield())
5264 if (F->isAnonymousStructOrUnion() && !Info.isImplicitCopyOrMove())
5273 if (Info.isImplicitCopyOrMove())
5276 if (
auto *F = dyn_cast<IndirectFieldDecl>(Mem)) {
5277 if (F->getType()->isIncompleteArrayType()) {
5279 "Incomplete array type is not valid");
5291 unsigned NumInitializers = Info.AllToInit.size();
5292 if (NumInitializers > 0) {
5293 Constructor->setNumCtorInitializers(NumInitializers);
5296 memcpy(baseOrMemberInitializers, Info.AllToInit.data(),
5298 Constructor->setCtorInitializers(baseOrMemberInitializers);
5302 MarkBaseAndMemberDestructorsReferenced(Constructor->getLocation(),
5303 Constructor->getParent());
5313 for (
auto *Field : RD->
fields())
5318 IdealInits.push_back(Field->getCanonicalDecl());
5327 if (!
Member->isAnyMemberInitializer())
5330 return Member->getAnyMember()->getCanonicalDecl();
5336 if (
Previous->isAnyMemberInitializer())
5341 if (Current->isAnyMemberInitializer())
5342 Diag << 0 << Current->getAnyMember();
5344 Diag << 1 << Current->getTypeSourceInfo()->getType();
5350 if (Constructor->getDeclContext()->isDependentContext())
5355 bool ShouldCheckOrder =
false;
5356 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5358 if (!SemaRef.
Diags.
isIgnored(diag::warn_initializer_out_of_order,
5359 Init->getSourceLocation())) {
5360 ShouldCheckOrder =
true;
5364 if (!ShouldCheckOrder)
5375 for (
const auto &VBase : ClassDecl->
vbases())
5379 for (
const auto &
Base : ClassDecl->
bases()) {
5380 if (
Base.isVirtual())
5386 for (
auto *Field : ClassDecl->
fields()) {
5387 if (Field->isUnnamedBitfield())
5393 unsigned NumIdealInits = IdealInitKeys.size();
5394 unsigned IdealIndex = 0;
5403 for (
unsigned InitIndex = 0; InitIndex != Inits.size(); ++InitIndex) {
5408 for (; IdealIndex != NumIdealInits; ++IdealIndex)
5409 if (InitKey == IdealInitKeys[IdealIndex])
5415 if (IdealIndex == NumIdealInits && InitIndex) {
5416 WarnIndexes.push_back(InitIndex);
5419 for (IdealIndex = 0; IdealIndex != NumIdealInits; ++IdealIndex)
5420 if (InitKey == IdealInitKeys[IdealIndex])
5423 assert(IdealIndex < NumIdealInits &&
5424 "initializer not found in initializer list");
5426 CorrelatedInitOrder.emplace_back(IdealIndex, InitIndex);
5429 if (WarnIndexes.empty())
5433 llvm::sort(CorrelatedInitOrder, llvm::less_first());
5439 Inits[WarnIndexes.front() - 1]->getSourceLocation(),
5440 WarnIndexes.size() == 1 ? diag::warn_initializer_out_of_order
5441 : diag::warn_some_initializers_out_of_order);
5443 for (
unsigned I = 0; I < CorrelatedInitOrder.size(); ++I) {
5444 if (CorrelatedInitOrder[I].second == I)
5450 Inits[I]->getSourceRange(),
5453 Inits[CorrelatedInitOrder[I].second]->getSourceRange()),
5459 if (WarnIndexes.size() == 1) {
5461 Inits[WarnIndexes.front()]);
5467 for (
unsigned WarnIndex : WarnIndexes) {
5470 diag::note_initializer_out_of_order);
5477bool CheckRedundantInit(
Sema &S,
5485 if (
FieldDecl *Field = Init->getAnyMember())
5486 S.
Diag(Init->getSourceLocation(),
5487 diag::err_multiple_mem_initialization)
5488 <<
Field->getDeclName()
5489 << Init->getSourceRange();
5491 const Type *BaseClass = Init->getBaseClass();
5492 assert(BaseClass &&
"neither field nor base");
5493 S.
Diag(Init->getSourceLocation(),
5494 diag::err_multiple_base_initialization)
5496 << Init->getSourceRange();
5504typedef std::pair<NamedDecl *, CXXCtorInitializer *> UnionEntry;
5505typedef llvm::DenseMap<RecordDecl*, UnionEntry> RedundantUnionMap;
5507bool CheckRedundantUnionInit(
Sema &S,
5509 RedundantUnionMap &Unions) {
5514 while (
Parent->isAnonymousStructOrUnion() ||
Parent->isUnion()) {
5516 UnionEntry &En = Unions[
Parent];
5517 if (En.first && En.first != Child) {
5518 S.
Diag(Init->getSourceLocation(),
5519 diag::err_multiple_mem_union_initialization)
5520 <<
Field->getDeclName()
5521 << Init->getSourceRange();
5522 S.
Diag(En.second->getSourceLocation(), diag::note_previous_initializer)
5523 << 0 << En.second->getSourceRange();
5530 if (!
Parent->isAnonymousStructOrUnion())
5547 if (!ConstructorDecl)
5550 AdjustDeclIfTemplate(ConstructorDecl);
5553 = dyn_cast<CXXConstructorDecl>(ConstructorDecl);
5556 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
5563 llvm::DenseMap<const void *, CXXCtorInitializer *> Members;
5566 RedundantUnionMap MemberUnions;
5568 bool HadError =
false;
5569 for (
unsigned i = 0; i < MemInits.size(); i++) {
5573 Init->setSourceOrder(i);
5575 if (Init->isAnyMemberInitializer()) {
5577 if (CheckRedundantInit(*
this, Init, Members[Key]) ||
5578 CheckRedundantUnionInit(*
this, Init, MemberUnions))
5580 }
else if (Init->isBaseInitializer()) {
5582 if (CheckRedundantInit(*
this, Init, Members[Key]))
5585 assert(Init->isDelegatingInitializer());
5587 if (MemInits.size() != 1) {
5588 Diag(Init->getSourceLocation(),
5589 diag::err_delegating_initializer_alone)
5590 << Init->getSourceRange() << MemInits[i ? 0 : 1]->getSourceRange();
5593 SetDelegatingInitializer(Constructor, MemInits[i]);
5604 SetCtorInitializers(Constructor, AnyErrors, MemInits);
5606 DiagnoseUninitializedFields(*
this, Constructor);
5623 for (
auto *Field : ClassDecl->
fields()) {
5624 if (Field->isInvalidDecl())
5647 assert(Dtor &&
"No dtor found for FieldClassDecl!");
5648 CheckDestructorAccess(Field->getLocation(), Dtor,
5649 PDiag(diag::err_access_dtor_field)
5650 << Field->getDeclName()
5653 MarkFunctionReferenced(Location, Dtor);
5654 DiagnoseUseOfDecl(Dtor, Location);
5659 bool VisitVirtualBases = !ClassDecl->
isAbstract();
5666 if (Dtor && Dtor->
isUsed())
5667 VisitVirtualBases =
false;
5673 for (
const auto &
Base : ClassDecl->
bases()) {
5679 if (
Base.isVirtual()) {
5680 if (!VisitVirtualBases)
5682 DirectVirtualBases.insert(RT);
5693 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5696 CheckDestructorAccess(
Base.getBeginLoc(), Dtor,
5697 PDiag(diag::err_access_dtor_base)
5698 <<
Base.getType() <<
Base.getSourceRange(),
5701 MarkFunctionReferenced(Location, Dtor);
5702 DiagnoseUseOfDecl(Dtor, Location);
5705 if (VisitVirtualBases)
5706 MarkVirtualBaseDestructorsReferenced(Location, ClassDecl,
5707 &DirectVirtualBases);
5712 llvm::SmallPtrSetImpl<const RecordType *> *DirectVirtualBases) {
5714 for (
const auto &VBase : ClassDecl->
vbases()) {
5719 if (DirectVirtualBases && DirectVirtualBases->count(RT))
5730 assert(Dtor &&
"No dtor found for BaseClassDecl!");
5731 if (CheckDestructorAccess(
5733 PDiag(diag::err_access_dtor_vbase)
5737 CheckDerivedToBaseConversion(
5739 diag::err_access_dtor_vbase, 0, ClassDecl->
getLocation(),
5743 MarkFunctionReferenced(Location, Dtor);
5744 DiagnoseUseOfDecl(Dtor, Location);
5753 = dyn_cast<CXXConstructorDecl>(CDtorDecl)) {
5754 SetCtorInitializers(Constructor,
false);
5755 DiagnoseUninitializedFields(*
this, Constructor);
5782 if (!isAbstractType(Loc, T))
5787 DiagnoseAbstractType(T->getAsCXXRecordDecl());
5794 if (PureVirtualClassDiagSet && PureVirtualClassDiagSet->count(RD))
5800 if (Diags.isLastDiagnosticIgnored())
5810 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
5811 MEnd = FinalOverriders.end();
5815 SOEnd = M->second.end();
5816 SO != SOEnd; ++SO) {
5823 if (SO->second.size() != 1)
5826 if (!SO->second.front().Method->isPure())
5829 if (!SeenPureMethods.insert(SO->second.front().Method).second)
5832 Diag(SO->second.front().Method->getLocation(),
5833 diag::note_pure_virtual_function)
5834 << SO->second.front().Method->getDeclName() << RD->
getDeclName();
5838 if (!PureVirtualClassDiagSet)
5840 PureVirtualClassDiagSet->insert(RD);
5844struct AbstractUsageInfo {
5851 : S(S), Record(Record),
5852 AbstractType(S.Context.getCanonicalType(
5853 S.Context.getTypeDeclType(Record))),
5856 void DiagnoseAbstractType() {
5865struct CheckAbstractUsage {
5866 AbstractUsageInfo &Info;
5869 CheckAbstractUsage(AbstractUsageInfo &Info,
const NamedDecl *Ctx)
5870 : Info(Info), Ctx(Ctx) {}
5874#define ABSTRACT_TYPELOC(CLASS, PARENT)
5875#define TYPELOC(CLASS, PARENT) \
5876 case TypeLoc::CLASS: Check(TL.castAs<CLASS##TypeLoc>(), Sel); break;
5877#include "clang/AST/TypeLocNodes.def"
5883 for (
unsigned I = 0, E = TL.
getNumParams(); I != E; ++I) {
5898 for (
unsigned I = 0, E = TL.
getNumArgs(); I != E; ++I) {
5908#define CheckPolymorphic(Type) \
5909 void Check(Type TL, Sema::AbstractDiagSelID Sel) { \
5910 Visit(TL.getNextTypeLoc(), Sema::AbstractNone); \
5925 return Visit(
Next, Sel);
5933 if (T->isArrayType()) {
5938 if (CT != Info.AbstractType)
return;
5949 Info.DiagnoseAbstractType();
5955 CheckAbstractUsage(*
this, D).Visit(TL, Sel);
5990 for (
auto *D : RD->
decls()) {
5991 if (D->isImplicit())
continue;
5994 if (
auto *FD = dyn_cast<FriendDecl>(D)) {
5995 D = FD->getFriendDecl();
6000 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
6002 }
else if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(D)) {
6006 }
else if (
auto *FD = dyn_cast<FieldDecl>(D)) {
6009 }
else if (
auto *VD = dyn_cast<VarDecl>(D)) {
6011 }
else if (
auto *VTD = dyn_cast<VarTemplateDecl>(D)) {
6015 }
else if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
6017 }
else if (
auto *CTD = dyn_cast<ClassTemplateDecl>(D)) {
6028 assert(ClassAttr->
getKind() == attr::DLLExport);
6038 struct MarkingClassDllexported {
6049 ~MarkingClassDllexported() {
6052 } MarkingDllexportedContext(S, Class, ClassAttr->
getLocation());
6059 if (!
Member->hasAttr<DLLExportAttr>())
6064 auto *VD = dyn_cast<VarDecl>(
Member);
6065 if (VD && VD->getStorageClass() ==
SC_Static &&
6069 auto *MD = dyn_cast<CXXMethodDecl>(
Member);
6073 if (MD->isUserProvided()) {
6083 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6093 }
else if (MD->isExplicitlyDefaulted()) {
6102 }
else if (!MD->isTrivial() ||
6103 MD->isCopyAssignmentOperator() ||
6104 MD->isMoveAssignmentOperator()) {
6128 auto *CD = dyn_cast<CXXConstructorDecl>(
Member);
6129 if (!CD || !CD->isDefaultConstructor())
6131 auto *
Attr = CD->getAttr<DLLExportAttr>();
6137 if (!Class->isDependentContext()) {
6144 if (LastExportedDefaultCtor) {
6146 diag::err_attribute_dll_ambiguous_default_ctor)
6148 S.
Diag(CD->getLocation(), diag::note_entity_declared_at)
6149 << CD->getDeclName();
6152 LastExportedDefaultCtor = CD;
6158 bool ErrorReported =
false;
6159 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6163 S.
Diag(TD->getLocation(),
6164 diag::err_cuda_device_builtin_surftex_cls_template)
6166 ErrorReported =
true;
6171 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6173 S.
Diag(Class->getLocation(),
6174 diag::err_cuda_device_builtin_surftex_ref_decl)
6176 S.
Diag(Class->getLocation(),
6177 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6181 TD = SD->getSpecializedTemplate();
6185 unsigned N = Params->
size();
6188 reportIllegalClassTemplate(S, TD);
6190 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6193 if (
N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6194 reportIllegalClassTemplate(S, TD);
6196 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6200 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6201 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6202 reportIllegalClassTemplate(S, TD);
6204 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6212 bool ErrorReported =
false;
6213 auto reportIllegalClassTemplate = [&ErrorReported](
Sema &S,
6217 S.
Diag(TD->getLocation(),
6218 diag::err_cuda_device_builtin_surftex_cls_template)
6220 ErrorReported =
true;
6225 auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(Class);
6227 S.
Diag(Class->getLocation(),
6228 diag::err_cuda_device_builtin_surftex_ref_decl)
6230 S.
Diag(Class->getLocation(),
6231 diag::note_cuda_device_builtin_surftex_should_be_template_class)
6235 TD = SD->getSpecializedTemplate();
6239 unsigned N = Params->
size();
6242 reportIllegalClassTemplate(S, TD);
6244 diag::note_cuda_device_builtin_surftex_cls_should_have_n_args)
6247 if (
N > 0 && !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
6248 reportIllegalClassTemplate(S, TD);
6250 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6254 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(1));
6255 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6256 reportIllegalClassTemplate(S, TD);
6258 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6263 auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Params->
getParam(2));
6264 if (!NTTP || !NTTP->getType()->isIntegralOrEnumerationType()) {
6265 reportIllegalClassTemplate(S, TD);
6267 diag::note_cuda_device_builtin_surftex_cls_should_have_match_arg)
6275 for (
auto *Method : Class->methods()) {
6276 if (Method->isUserProvided())
6278 if (
Attr *A = getImplicitCodeSegOrSectionAttrForFunction(Method,
true))
6289 if (
auto *Spec = dyn_cast<ClassTemplatePartialSpecializationDecl>(Class)) {
6290 if (
Attr *TemplateAttr =
6291 getDLLAttr(Spec->getSpecializedTemplate()->getTemplatedDecl())) {
6293 A->setInherited(
true);
6302 if (!Class->isExternallyVisible()) {
6303 Diag(Class->getLocation(), diag::err_attribute_dll_not_extern)
6304 << Class << ClassAttr;
6312 if (!isa<VarDecl>(
Member) && !isa<CXXMethodDecl>(
Member))
6319 diag::err_attribute_dll_member_of_dll_class)
6320 << MemberAttr << ClassAttr;
6321 Diag(ClassAttr->getLocation(), diag::note_previous_attribute);
6322 Member->setInvalidDecl();
6326 if (Class->getDescribedClassTemplate())
6331 const bool ClassExported = ClassAttr->
getKind() == attr::DLLExport;
6336 const bool PropagatedImport =
6347 Class->dropAttr<DLLExportAttr>();
6352 ForceDeclarationOfImplicitMembers(Class);
6381 auto *Ctor = dyn_cast<CXXConstructorDecl>(MD);
6390 (Ctor || isa<CXXDestructorDecl>(MD)) && MD->
isTrivial())
6397 if (VD && PropagatedImport)
6408 if (!getLangOpts().DllExportInlines && MD && MD->
isInlined() &&
6411 if (ClassExported) {
6412 NewAttr = ::new (getASTContext())
6413 DLLExportStaticLocalAttr(getASTContext(), *ClassAttr);
6415 NewAttr = ::new (getASTContext())
6416 DLLImportStaticLocalAttr(getASTContext(), *ClassAttr);
6423 Member->addAttr(NewAttr);
6433 "friend re-decl should not already have a DLLAttr");
6443 DelayedDllExportClasses.push_back(Class);
6465 NewAttr->setInherited(
true);
6466 BaseTemplateSpec->
addAttr(NewAttr);
6470 if (
auto *ImportAttr = dyn_cast<DLLImportAttr>(NewAttr))
6471 ImportAttr->setPropagatedToBaseTemplate();
6477 checkClassLevelDLLAttribute(BaseTemplateSpec);
6492 Diag(BaseLoc, diag::warn_attribute_dll_instantiated_base_class)
6497 diag::note_template_class_explicit_specialization_was_here)
6498 << BaseTemplateSpec;
6501 diag::note_template_class_instantiation_was_here)
6502 << BaseTemplateSpec;
6515 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
6527 if (MD->isCopyAssignmentOperator())
6530 if (MD->isMoveAssignmentOperator())
6533 if (isa<CXXDestructorDecl>(FD))
6539 return DefaultedComparisonKind::Equal;
6541 case OO_ExclaimEqual:
6542 return DefaultedComparisonKind::NotEqual;
6548 return DefaultedComparisonKind::ThreeWay;
6553 case OO_GreaterEqual:
6557 return DefaultedComparisonKind::Relational;
6576 cast<CXXConstructorDecl>(FD));
6594 llvm_unreachable(
"Invalid special member.");
6612 bool CopyCtorIsTrivial =
false, CopyCtorIsTrivialForCall =
false;
6613 bool DtorIsTrivialForCall =
false;
6624 CopyCtorIsTrivial =
true;
6626 CopyCtorIsTrivialForCall =
true;
6630 if (CD->isCopyConstructor() && !CD->isDeleted()) {
6631 if (CD->isTrivial())
6632 CopyCtorIsTrivial =
true;
6633 if (CD->isTrivialForCall())
6634 CopyCtorIsTrivialForCall =
true;
6642 DtorIsTrivialForCall =
true;
6644 if (!DD->isDeleted() && DD->isTrivialForCall())
6645 DtorIsTrivialForCall =
true;
6649 if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
6663 uint64_t TypeSize = isAArch64 ? 128 : 64;
6665 if (CopyCtorIsTrivial &&
6675 bool HasNonDeletedCopyOrMove =
false;
6681 HasNonDeletedCopyOrMove =
true;
6688 HasNonDeletedCopyOrMove =
true;
6696 if (MD->isDeleted() || MD->isIneligibleOrNotSelected())
6699 auto *CD = dyn_cast<CXXConstructorDecl>(MD);
6700 if (CD && CD->isCopyOrMoveConstructor())
6701 HasNonDeletedCopyOrMove =
true;
6702 else if (!isa<CXXDestructorDecl>(MD))
6705 if (!MD->isTrivialForCall())
6709 return HasNonDeletedCopyOrMove;
6720 bool IssuedDiagnostic =
false;
6723 if (!IssuedDiagnostic) {
6725 IssuedDiagnostic =
true;
6727 S.
Diag(O->getLocation(), diag::note_overridden_virtual_function);
6730 return IssuedDiagnostic;
6744 if (Record->isAbstract() && !Record->isInvalidDecl()) {
6745 AbstractUsageInfo Info(*
this, Record);
6752 if (!Record->isInvalidDecl() && !Record->isDependentType() &&
6753 !Record->isAggregate() && !Record->hasUserDeclaredConstructor() &&
6754 !Record->isLambda()) {
6755 bool Complained =
false;
6756 for (
const auto *F : Record->fields()) {
6757 if (F->hasInClassInitializer() || F->isUnnamedBitfield())
6760 if (F->getType()->isReferenceType() ||
6761 (F->getType().isConstQualified() && F->getType()->isScalarType())) {
6763 Diag(Record->getLocation(), diag::warn_no_constructor_for_refconst)
6764 << Record->getTagKind() << Record;
6768 Diag(F->getLocation(), diag::note_refconst_member_not_initialized)
6769 << F->getType()->isReferenceType()
6770 << F->getDeclName();
6775 if (Record->getIdentifier()) {
6788 if (((isa<FieldDecl>(D) || isa<UnresolvedUsingValueDecl>(D)) &&
6789 Record->hasUserDeclaredConstructor()) ||
6790 isa<IndirectFieldDecl>(D)) {
6791 Diag((*I)->getLocation(), diag::err_member_name_of_class)
6799 if (Record->isPolymorphic() && !Record->isDependentType()) {
6802 !Record->hasAttr<FinalAttr>())
6804 diag::warn_non_virtual_dtor) << Context.
getRecordType(Record);
6807 if (Record->isAbstract()) {
6808 if (FinalAttr *FA = Record->getAttr<FinalAttr>()) {
6809 Diag(Record->getLocation(), diag::warn_abstract_final_class)
6810 << FA->isSpelledAsSealed();
6811 DiagnoseAbstractType(Record);
6816 if (!Record->hasAttr<FinalAttr>()) {
6818 if (
const FinalAttr *FA = dtor->getAttr<FinalAttr>()) {
6819 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
6820 << FA->isSpelledAsSealed()
6822 getLocForEndOfToken(Record->getLocation()),
6823 (FA->isSpelledAsSealed() ?
" sealed" :
" final"));
6824 Diag(Record->getLocation(),
6825 diag::note_final_dtor_non_final_class_silence)
6826 << Context.
getRecordType(Record) << FA->isSpelledAsSealed();
6832 if (Record->hasAttr<TrivialABIAttr>())
6833 checkIllFormedTrivialABIStruct(*Record);
6837 bool HasTrivialABI = Record->hasAttr<TrivialABIAttr>();
6840 Record->setHasTrivialSpecialMemberForCall();
6850 auto CheckCompletedMemberFunction = [&](
CXXMethodDecl *MD) {
6861 MD->
isDeleted() ? diag::err_deleted_override
6862 : diag::err_non_deleted_override,
6864 return MD->isDeleted() != V->isDeleted();
6868 DiagnoseDeletedDefaultedFunction(MD);
6876 : diag::err_non_consteval_override,
6878 return MD->isConsteval() != V->isConsteval();
6882 DiagnoseDeletedDefaultedFunction(MD);
6887 auto CheckForDefaultedFunction = [&](
FunctionDecl *FD) ->
bool {
6888 if (!FD || FD->
isInvalidDecl() || !FD->isExplicitlyDefaulted())
6892 if (DFK.
asComparison() == DefaultedComparisonKind::NotEqual ||
6893 DFK.
asComparison() == DefaultedComparisonKind::Relational) {
6894 DefaultedSecondaryComparisons.push_back(FD);
6898 CheckExplicitlyDefaultedFunction(S, FD);
6904 bool Incomplete = CheckForDefaultedFunction(M);
6907 if (Record->isDependentType())
6913 if (!M->isImplicit() && !M->isUserProvided()) {
6914 if (CSM != CXXInvalid) {
6915 M->setTrivial(SpecialMemberIsTrivial(M, CSM));
6917 Record->finishedDefaultedOrDeletedMember(M);
6918 M->setTrivialForCall(
6920 SpecialMemberIsTrivial(M, CSM, TAH_ConsiderTrivialABI));
6921 Record->setTrivialForCallFlags(M);
6927 if ((CSM == CXXCopyConstructor || CSM == CXXMoveConstructor ||
6928 CSM == CXXDestructor) && M->isUserProvided()) {
6929 M->setTrivialForCall(HasTrivialABI);
6930 Record->setTrivialForCallFlags(M);
6933 if (!M->isInvalidDecl() && M->isExplicitlyDefaulted() &&
6934 M->hasAttr<DLLExportAttr>()) {
6937 (CSM == CXXDefaultConstructor || CSM == CXXCopyConstructor ||
6938 CSM == CXXDestructor))
6939 M->dropAttr<DLLExportAttr>();
6941 if (M->hasAttr<DLLExportAttr>()) {
6943 DelayedDllExportMemberFunctions.push_back(M);
6950 if (M->isDefaulted() && M->isConstexpr() && M->size_overridden_methods())
6954 CheckCompletedMemberFunction(M);
6963 CompleteMemberFunction(Dtor);
6965 bool HasMethodWithOverrideControl =
false,
6966 HasOverridingMethodWithoutOverrideControl =
false;
6967 for (
auto *D : Record->decls()) {
6968 if (
auto *M = dyn_cast<CXXMethodDecl>(D)) {
6971 if (!Record->isDependentType()) {
6975 DiagnoseHiddenVirtualMethods(M);
6976 if (M->hasAttr<OverrideAttr>())
6977 HasMethodWithOverrideControl =
true;
6978 else if (M->size_overridden_methods() > 0)
6979 HasOverridingMethodWithoutOverrideControl =
true;
6982 if (!isa<CXXDestructorDecl>(M))
6983 CompleteMemberFunction(M);
6984 }
else if (
auto *F = dyn_cast<FriendDecl>(D)) {
6985 CheckForDefaultedFunction(
6986 dyn_cast_or_null<FunctionDecl>(F->getFriendDecl()));
6990 if (HasOverridingMethodWithoutOverrideControl) {
6991 bool HasInconsistentOverrideControl = HasMethodWithOverrideControl;
6992 for (
auto *M : Record->methods())
6993 DiagnoseAbsenceOfOverrideControl(M, HasInconsistentOverrideControl);
6997 for (
FunctionDecl *FD : DefaultedSecondaryComparisons) {
6998 CheckExplicitlyDefaultedFunction(S, FD);
7001 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD))
7002 CheckCompletedMemberFunction(MD);
7018 if (Record->isMsStruct(Context) && !Context.
getLangOpts().MSBitfields &&
7019 (Record->isPolymorphic() || Record->getNumBases())) {
7020 Diag(Record->getLocation(), diag::warn_cxx_ms_struct);
7023 checkClassLevelDLLAttribute(Record);
7024 checkClassLevelCodeSegAttribute(Record);
7026 bool ClangABICompat4 =
7027 Context.
getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver4;
7035 Record->setArgPassingRestrictions(CanPass
7044 Record->setParamDestroyedInCallee(
true);
7045 else if (Record->hasNonTrivialDestructor())
7046 Record->setParamDestroyedInCallee(CanPass);
7048 if (getLangOpts().ForceEmitVTables) {
7051 MarkVTableUsed(Record->getInnerLocStart(), Record);
7054 if (getLangOpts().
CUDA) {
7055 if (Record->hasAttr<CUDADeviceBuiltinSurfaceTypeAttr>())
7057 else if (Record->hasAttr<CUDADeviceBuiltinTextureTypeAttr>())
7073 unsigned FieldQuals,
bool ConstRHS) {
7074 unsigned LHSQuals = 0;
7076 LHSQuals = FieldQuals;
7078 unsigned RHSQuals = FieldQuals;
7099 llvm::DenseMap<CXXRecordDecl *, ConstructorUsingShadowDecl *>
7105 : S(S), UseLoc(UseLoc) {
7106 bool DiagnosedMultipleConstructedBases =
false;
7112 for (
auto *D : Shadow->
redecls()) {
7113 auto *DShadow = cast<ConstructorUsingShadowDecl>(D);
7114 auto *DNominatedBase = DShadow->getNominatedBaseClass();
7115 auto *DConstructedBase = DShadow->getConstructedBaseClass();
7117 InheritedFromBases.insert(
7118 std::make_pair(DNominatedBase->getCanonicalDecl(),
7119 DShadow->getNominatedBaseClassShadowDecl()));
7120 if (DShadow->constructsVirtualBase())
7121 InheritedFromBases.insert(
7122 std::make_pair(DConstructedBase->getCanonicalDecl(),
7123 DShadow->getConstructedBaseClassShadowDecl()));
7125 assert(DNominatedBase == DConstructedBase);
7130 if (!ConstructedBase) {
7131 ConstructedBase = DConstructedBase;
7132 ConstructedBaseIntroducer = D->getIntroducer();
7133 }
else if (ConstructedBase != DConstructedBase &&
7135 if (!DiagnosedMultipleConstructedBases) {
7136 S.Diag(UseLoc, diag::err_ambiguous_inherited_constructor)
7137 << Shadow->getTargetDecl();
7138 S.Diag(ConstructedBaseIntroducer->getLocation(),
7139 diag::note_ambiguous_inherited_constructor_using)
7141 DiagnosedMultipleConstructedBases = true;
7143 S.
Diag(D->getIntroducer()->getLocation(),
7144 diag::note_ambiguous_inherited_constructor_using)
7145 << DConstructedBase;
7149 if (DiagnosedMultipleConstructedBases)
7150 Shadow->setInvalidDecl();
7156 std::pair<CXXConstructorDecl *, bool>
7158 auto It = InheritedFromBases.find(
Base->getCanonicalDecl());
7159 if (It == InheritedFromBases.end())
7160 return std::make_pair(
nullptr,
false);
7164 return std::make_pair(
7166 It->second->constructsVirtualBase());
7169 return std::make_pair(Ctor,
false);
7183 if (InheritedCtor) {
7186 Inherited->findConstructorForBase(ClassDecl, InheritedCtor).first;
7188 return BaseCtor->isConstexpr();
7256 if (Ctor && ClassDecl->
isUnion())
7275 for (
const auto &B : ClassDecl->
bases()) {
7277 if (!BaseType)
continue;
7281 InheritedCtor, Inherited))
7292 for (
const auto *F : ClassDecl->
fields()) {
7293 if (F->isInvalidDecl())
7301 BaseType.getCVRQualifiers(),
7302 ConstArg && !F->isMutable()))
7316struct ComputingExceptionSpec {
7327 ~ComputingExceptionSpec() {
7346 if (DFK.isSpecialMember())
7348 S, Loc, cast<CXXMethodDecl>(FD), DFK.asSpecialMember(),
nullptr);
7349 if (DFK.isComparison())
7351 DFK.asComparison());
7354 assert(CD->getInheritedConstructor() &&
7355 "only defaulted functions and inherited constructors have implicit "
7358 S, Loc, CD->getInheritedConstructor().getShadowDecl());
7385 auto ESI = IES.getExceptionSpec();
7388 UpdateExceptionSpec(FD, ESI);
7401 UnusedPrivateFields.clear();
7404 ? CheckExplicitlyDefaultedSpecialMember(cast<CXXMethodDecl>(FD),
7406 : CheckExplicitlyDefaultedComparison(S, FD, DefKind.
asComparison()))
7415 "not an explicitly-defaulted special member");
7425 bool HadError =
false;
7437 bool DeleteOnTypeMismatch = getLangOpts().CPlusPlus20 &&
First;
7438 bool ShouldDeleteForTypeMismatch =
false;
7439 unsigned ExpectedParams = 1;
7440 if (CSM == CXXDefaultConstructor || CSM == CXXDestructor)
7450 if (DeleteOnTypeMismatch)
7451 ShouldDeleteForTypeMismatch =
true;
7461 bool CanHaveConstParam =
false;
7462 if (CSM == CXXCopyConstructor)
7464 else if (CSM == CXXCopyAssignment)
7468 if (CSM == CXXCopyAssignment || CSM == CXXMoveAssignment) {
7470 ReturnType =
Type->getReturnType();
7476 if (!Context.
hasSameType(ReturnType, ExpectedReturnType)) {
7477 Diag(MD->
getLocation(), diag::err_defaulted_special_member_return_type)
7478 << (CSM == CXXMoveAssignment) << ExpectedReturnType;
7483 if (
Type->getMethodQuals().hasConst() ||
Type->getMethodQuals().hasVolatile()) {
7484 if (DeleteOnTypeMismatch)
7485 ShouldDeleteForTypeMismatch =
true;
7488 << (CSM == CXXMoveAssignment) << getLangOpts().CPlusPlus14;
7496 bool HasConstParam =
false;
7497 if (ExpectedParams && ArgType->isReferenceType()) {
7503 if (DeleteOnTypeMismatch)
7504 ShouldDeleteForTypeMismatch =
true;
7507 diag::err_defaulted_special_member_volatile_param) << CSM;
7512 if (HasConstParam && !CanHaveConstParam) {
7513 if (DeleteOnTypeMismatch)
7514 ShouldDeleteForTypeMismatch =
true;
7515 else if (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment) {
7517 diag::err_defaulted_special_member_copy_const_param)
7518 << (CSM == CXXCopyAssignment);
7523 diag::err_defaulted_special_member_move_const_param)
7524 << (CSM == CXXMoveAssignment);
7528 }
else if (ExpectedParams) {
7531 assert(CSM == CXXCopyAssignment &&
"unexpected non-ref argument");
7548 (getLangOpts().
CPlusPlus14 ? !isa<CXXDestructorDecl>(MD)
7549 : isa<CXXConstructorDecl>(MD))) &&
7553 ? diag::err_incorrect_defaulted_consteval
7554 : diag::err_incorrect_defaulted_constexpr)
7566 ? ConstexprSpecKind::Consteval
7567 : ConstexprSpecKind::Constexpr)
7568 : ConstexprSpecKind::Unspecified);
7570 if (!
Type->hasExceptionSpec()) {
7579 llvm::makeArrayRef(&ArgType,
7585 if (ShouldDeleteForTypeMismatch || ShouldDeleteSpecialMember(MD, CSM)) {
7588 if (!inTemplateInstantiation() && !HadError) {
7590 if (ShouldDeleteForTypeMismatch) {
7593 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
7596 if (ShouldDeleteForTypeMismatch && !HadError) {
7598 diag::warn_cxx17_compat_defaulted_method_type_mismatch) << CSM;
7604 Diag(MD->
getLocation(), diag::err_out_of_line_default_deletes) << CSM;
7605 assert(!ShouldDeleteForTypeMismatch &&
"deleted non-first decl");
7606 ShouldDeleteSpecialMember(MD, CSM,
nullptr,
true);
7627template<
typename Derived,
typename ResultList,
typename Result,
7629class DefaultedComparisonVisitor {
7634 DefaultedComparisonKind DCK)
7635 : S(S), RD(RD), FD(FD), DCK(DCK) {
7639 Fns.assign(Info->getUnqualifiedLookups().begin(),
7640 Info->getUnqualifiedLookups().end());
7644 ResultList visit() {
7652 case DefaultedComparisonKind::None:
7653 llvm_unreachable(
"not a defaulted comparison");
7655 case DefaultedComparisonKind::Equal:
7656 case DefaultedComparisonKind::ThreeWay:
7657 getDerived().visitSubobjects(Results, RD, ParamLvalType.
getQualifiers());
7660 case DefaultedComparisonKind::NotEqual:
7661 case DefaultedComparisonKind::Relational:
7662 Results.add(getDerived().visitExpandedSubobject(
7663 ParamLvalType, getDerived().getCompleteObject()));
7666 llvm_unreachable(
"");
7670 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
7676 bool visitSubobjects(ResultList &Results,
CXXRecordDecl *Record,
7681 if (Results.add(getDerived().visitSubobject(
7683 getDerived().getBase(&
Base))))
7689 if (
Field->isAnonymousStructOrUnion()) {
7690 if (visitSubobjects(Results,
Field->getType()->getAsCXXRecordDecl(),
7698 if (
Field->isMutable())
7703 if (Results.add(getDerived().visitSubobject(
7704 FieldType, getDerived().getField(Field))))
7712 Result visitSubobject(
QualType Type, Subobject Subobj) {
7715 if (
auto *CAT = dyn_cast_or_null<ConstantArrayType>(AT))
7716 return getDerived().visitSubobjectArray(CAT->getElementType(),
7717 CAT->getSize(), Subobj);
7718 return getDerived().visitExpandedSubobject(
Type, Subobj);
7721 Result visitSubobjectArray(
QualType Type,
const llvm::APInt &Size,
7723 return getDerived().visitSubobject(
Type, Subobj);
7730 DefaultedComparisonKind DCK;
7736struct DefaultedComparisonInfo {
7741 static DefaultedComparisonInfo deleted() {
7742 DefaultedComparisonInfo
Deleted;
7747 bool add(
const DefaultedComparisonInfo &R) {
7757struct DefaultedComparisonSubobject {
7765class DefaultedComparisonAnalyzer
7766 :
public DefaultedComparisonVisitor<DefaultedComparisonAnalyzer,
7767 DefaultedComparisonInfo,
7768 DefaultedComparisonInfo,
7769 DefaultedComparisonSubobject> {
7771 enum DiagnosticKind { NoDiagnostics, ExplainDeleted, ExplainConstexpr };
7774 DiagnosticKind Diagnose;
7777 using Base = DefaultedComparisonVisitor;
7778 using Result = DefaultedComparisonInfo;
7779 using Subobject = DefaultedComparisonSubobject;
7784 DefaultedComparisonKind DCK,
7785 DiagnosticKind Diagnose = NoDiagnostics)
7786 :
Base(S, RD, FD, DCK), Diagnose(Diagnose) {}
7789 if ((DCK == DefaultedComparisonKind::Equal ||
7790 DCK == DefaultedComparisonKind::ThreeWay) &&
7795 if (Diagnose == ExplainDeleted) {
7799 return Result::deleted();
7802 return Base::visit();
7806 Subobject getCompleteObject() {
7807 return Subobject{Subobject::CompleteObject, RD, FD->
getLocation()};
7811 return Subobject{Subobject::Base,
Base->getType()->getAsCXXRecordDecl(),
7812 Base->getBaseTypeLoc()};
7816 return Subobject{Subobject::Member,
Field,
Field->getLocation()};
7819 Result visitExpandedSubobject(
QualType Type, Subobject Subobj) {
7824 if (Diagnose == ExplainDeleted) {
7825 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_reference_member)
7828 return Result::deleted();
7833 Expr *Args[] = {&Xi, &Xi};
7837 assert(OO !=
OO_None &&
"not an overloaded operator!");
7838 return visitBinaryOperator(OO, Args, Subobj);
7851 OO, !SpaceshipCandidates));
7856 CandidateSet.exclude(FD);
7858 if (Args[0]->
getType()->isOverloadableType())
7869 switch (CandidateSet.BestViableFunction(S, FD->
getLocation(), Best)) {
7875 if ((DCK == DefaultedComparisonKind::NotEqual ||
7876 DCK == DefaultedComparisonKind::Relational) &&
7877 !Best->RewriteKind) {
7878 if (Diagnose == ExplainDeleted) {
7879 if (Best->Function) {
7880 S.
Diag(Best->Function->getLocation(),
7881 diag::note_defaulted_comparison_not_rewritten_callee)
7884 assert(Best->Conversions.size() == 2 &&
7885 Best->Conversions[0].isUserDefined() &&
7886 "non-user-defined conversion from class to built-in "
7888 S.
Diag(Best->Conversions[0]
7889 .UserDefined.FoundConversionFunction.getDecl()
7891 diag::note_defaulted_comparison_not_rewritten_conversion)
7895 return Result::deleted();
7905 CXXRecordDecl *ArgClass = Args[0]->getType()->getAsCXXRecordDecl();
7906 if (ArgClass && Best->FoundDecl.getDecl() &&
7907 Best->FoundDecl.getDecl()->isCXXClassMember()) {
7908 QualType ObjectType = Subobj.Kind == Subobject::Member
7909 ? Args[0]->getType()
7912 ArgClass, Best->FoundDecl, ObjectType, Subobj.Loc,
7913 Diagnose == ExplainDeleted
7914 ? S.
PDiag(diag::note_defaulted_comparison_inaccessible)
7915 << FD << Subobj.Kind << Subobj.Decl
7917 return Result::deleted();
7920 bool NeedsDeducing =
7928 assert(!BestFD->isDeleted() &&
"wrong overload resolution result");
7930 if (Diagnose == ExplainConstexpr && !BestFD->isConstexpr()) {
7931 if (Subobj.Kind != Subobject::CompleteObject)
7932 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_not_constexpr)
7933 << Subobj.
Kind << Subobj.Decl;
7934 S.
Diag(BestFD->getLocation(),
7935 diag::note_defaulted_comparison_not_constexpr_here);
7937 return Result::deleted();
7939 R.Constexpr &= BestFD->isConstexpr();
7941 if (NeedsDeducing) {
7946 if (BestFD->getReturnType()->isUndeducedType() &&
7952 if (Diagnose == NoDiagnostics) {
7955 diag::err_defaulted_comparison_cannot_deduce_undeduced_auto)
7956 << Subobj.
Kind << Subobj.Decl;
7959 diag::note_defaulted_comparison_cannot_deduce_undeduced_auto)
7960 << Subobj.
Kind << Subobj.Decl;
7961 S.
Diag(BestFD->getLocation(),
7962 diag::note_defaulted_comparison_cannot_deduce_callee)
7963 << Subobj.
Kind << Subobj.Decl;
7965 return Result::deleted();
7968 BestFD->getCallResultType());
7970 if (Diagnose == ExplainDeleted) {
7971 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_cannot_deduce)
7972 << Subobj.
Kind << Subobj.Decl
7973 << BestFD->getCallResultType().withoutLocalFastQualifiers();
7974 S.
Diag(BestFD->getLocation(),
7975 diag::note_defaulted_comparison_cannot_deduce_callee)
7976 << Subobj.
Kind << Subobj.Decl;
7978 return Result::deleted();
7980 R.Category = Info->Kind;
7983 QualType T = Best->BuiltinParamTypes[0];
7984 assert(T == Best->BuiltinParamTypes[1] &&
7985 "builtin comparison for different types?");
7986 assert(Best->BuiltinParamTypes[2].isNull() &&
7987 "invalid builtin comparison");
7989 if (NeedsDeducing) {
7992 assert(Cat &&
"no category for builtin comparison?");
8003 if (Diagnose == ExplainDeleted) {
8006 Kind = OO == OO_EqualEqual ? 1 : 2;
8007 CandidateSet.NoteCandidates(
8009 Subobj.Loc, S.
PDiag(diag::note_defaulted_comparison_ambiguous)
8010 << FD << Kind << Subobj.Kind << Subobj.Decl),
8013 R = Result::deleted();
8017 if (Diagnose == ExplainDeleted) {
8018 if ((DCK == DefaultedComparisonKind::NotEqual ||
8019 DCK == DefaultedComparisonKind::Relational) &&
8020 !Best->RewriteKind) {
8021 S.
Diag(Best->Function->getLocation(),
8022 diag::note_defaulted_comparison_not_rewritten_callee)
8026 diag::note_defaulted_comparison_calls_deleted)
8027 << FD << Subobj.
Kind << Subobj.Decl;
8031 R = Result::deleted();
8037 if (OO == OO_Spaceship &&
8041 if (!R.add(visitBinaryOperator(OO_EqualEqual, Args, Subobj,
8043 R.add(visitBinaryOperator(OO_Less, Args, Subobj, &CandidateSet));
8047 if (Diagnose == ExplainDeleted) {
8048 S.
Diag(Subobj.Loc, diag::note_defaulted_comparison_no_viable_function)
8049 << FD << (OO == OO_ExclaimEqual) << Subobj.
Kind << Subobj.Decl;
8053 if (SpaceshipCandidates) {
8054 SpaceshipCandidates->NoteCandidates(
8059 diag::note_defaulted_comparison_no_viable_function_synthesized)
8060 << (OO == OO_EqualEqual ? 0 : 1);
8063 CandidateSet.NoteCandidates(
8068 R = Result::deleted();
8077struct StmtListResult {
8078 bool IsInvalid =
false;
8081 bool add(
const StmtResult &S) {
8082 IsInvalid |= S.isInvalid();
8085 Stmts.push_back(S.get());
8092class DefaultedComparisonSynthesizer
8093 :
public DefaultedComparisonVisitor<DefaultedComparisonSynthesizer,
8094 StmtListResult, StmtResult,
8095 std::pair<ExprResult, ExprResult>> {
8097 unsigned ArrayDepth = 0;
8100 using Base = DefaultedComparisonVisitor;
8101 using ExprPair = std::pair<ExprResult, ExprResult>;
8106 DefaultedComparisonKind DCK,
8108 :
Base(S, RD, FD, DCK), Loc(BodyLoc) {}
8111 StmtResult build() {
8114 StmtListResult Stmts = visit();
8115 if (Stmts.IsInvalid)
8120 case DefaultedComparisonKind::None:
8121 llvm_unreachable(
"not a defaulted comparison");
8123 case DefaultedComparisonKind::Equal: {
8132 auto OldStmts = std::move(Stmts.Stmts);
8133 Stmts.Stmts.clear();
8136 auto FinishCmp = [&] {
8137 if (
Expr *Prior = CmpSoFar.
get()) {
8139 if (RetVal.
isUnset() && Stmts.Stmts.empty())
8142 else if (Stmts.add(buildIfNotCondReturnFalse(Prior)))
8148 for (
Stmt *EAsStmt : llvm::reverse(OldStmts)) {
8149 Expr *E = dyn_cast<Expr>(EAsStmt);
8152 if (FinishCmp() || Stmts.add(EAsStmt))
8167 std::reverse(Stmts.Stmts.begin(), Stmts.Stmts.end());
8174 case DefaultedComparisonKind::ThreeWay: {
8178 ComparisonCategoryType::StrongOrdering, Loc,
8179 Sema::ComparisonCategoryUsage::DefaultedOperator);
8185 RetVal = getDecl(EqualVD);
8188 RetVal = buildStaticCastToR(RetVal.
get());
8192 case DefaultedComparisonKind::NotEqual:
8193 case DefaultedComparisonKind::Relational:
8194 RetVal =
cast<Expr>(Stmts.Stmts.pop_back_val());
8220 ExprPair getCompleteObject() {
8223 if (isa<CXXMethodDecl>(FD)) {
8229 LHS = getParam(Param++);
8237 ExprPair Obj = getCompleteObject();
8238 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8248 ExprPair Obj = getCompleteObject();
8249 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8264 if (
Cond.isInvalid())
8272 assert(!False.
isInvalid() &&
"should never fail");
8274 if (ReturnFalse.isInvalid())
8277 return S.
ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc,
nullptr,
8279 Sema::ConditionKind::Boolean),
8283 StmtResult visitSubobjectArray(
QualType Type, llvm::APInt Size,
8292 llvm::raw_svector_ostream
OS(Str);
8293 OS <<
"i" << ArrayDepth;
8304 auto IterRef = [&] {
8308 assert(!Ref.
isInvalid() &&
"can't reference our own variable?");
8314 Loc, BO_NE, IterRef(),
8316 assert(!
Cond.isInvalid() &&
"should never fail");
8320 assert(!Inc.
isInvalid() &&
"should never fail");
8328 Subobj.first = Index(Subobj.first);
8329 Subobj.second = Index(Subobj.second);
8333 StmtResult Substmt = visitSubobject(
Type, Subobj);
8336 if (Substmt.isInvalid())
8342 if (
Expr *ElemCmp = dyn_cast<Expr>(Substmt.get())) {
8343 assert(DCK == DefaultedComparisonKind::Equal &&
8344 "should have non-expression statement");
8345 Substmt = buildIfNotCondReturnFalse(ElemCmp);
8346 if (Substmt.isInvalid())
8353 Sema::ConditionKind::Boolean),
8358 StmtResult visitExpandedSubobject(
QualType Type, ExprPair Obj) {
8359 if (Obj.first.isInvalid() || Obj.second.isInvalid())
8367 Obj.second.get(),
true,
8375 case DefaultedComparisonKind::None:
8376 llvm_unreachable(
"not a defaulted comparison");
8378 case DefaultedComparisonKind::Equal:
8386 case DefaultedComparisonKind::ThreeWay: {
8391 Op = buildStaticCastToR(Op.
get());
8419 nullptr, Loc, Comp.
get(), Sema::ConditionKind::Boolean);
8420 if (
Cond.isInvalid())
8424 VDRef = getDecl(VD);
8432 return S.
ActOnIfStmt(Loc, IfStatementKind::Ordinary, Loc, InitStmt,
Cond,
8437 case DefaultedComparisonKind::NotEqual:
8438 case DefaultedComparisonKind::Relational:
8443 llvm_unreachable(
"");
8449 assert(!R->
isUndeducedType() &&
"type should have been deduced already");
8480 if (Op == OO_Spaceship) {
8481 Lookup(OO_ExclaimEqual);
8483 Lookup(OO_EqualEqual);
8489 assert(DCK != DefaultedComparisonKind::None &&
"not a defaulted comparison");
8498 Context, Operators.
pairs()));
8513 assert(!MD->isStatic() &&
"comparison function cannot be a static member");
8519 if (!MD->isConst()) {
8522 InsertLoc = getLocForEndOfToken(Loc.getRParenLoc());
8525 if (!MD->isImplicit()) {
8526 Diag(MD->getLocation(), diag::err_defaulted_comparison_non_const)
8535 FPT->getParamTypes(), EPI));
8543 <<
int(IsMethod) <<
int(DCK);
8549 QualType ParmTy = Param->getType();
8555 bool Ok = !IsMethod;
8560 CTy = Ref->getPointeeType();
8571 }
else if (
auto *CRD = CTy->getAsRecordDecl()) {
8588 <<
int(DCK) << ParmTy << RefTy <<
int(!IsMethod) << PlainTy
8589 << Param->getSourceRange();
8591 assert(!IsMethod &&
"should know expected type for method");
8593 diag::err_defaulted_comparison_param_unknown)
8594 <<
int(DCK) << ParmTy << Param->getSourceRange();
8600 Diag(FD->
getLocation(), diag::err_defaulted_comparison_param_mismatch)
8602 << ParmTy << Param->getSourceRange();
8607 assert(RD &&
"must have determined class");
8616 diag::err_defaulted_comparison_not_friend,
int(DCK),
8621 return FD->getCanonicalDecl() ==
8622 F->getFriendDecl()->getCanonicalDecl();
8625 <<
int(DCK) <<
int(0) << RD;
8634 if (DCK != DefaultedComparisonKind::ThreeWay &&
8637 Diag(FD->
getLocation(), diag::err_defaulted_comparison_return_type_not_bool)
8645 if (DCK == DefaultedComparisonKind::ThreeWay &&
8650 diag::err_defaulted_comparison_deduced_return_type_not_auto)
8662 DefaultedComparisonInfo Info =
8663 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK).visit();
8679 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8680 DefaultedComparisonAnalyzer::ExplainDeleted)
8686 if (!inTemplateInstantiation() && !FD->
isImplicit()) {
8689 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8690 DefaultedComparisonAnalyzer::ExplainDeleted)
8698 if (DCK == DefaultedComparisonKind::ThreeWay &&
8705 QualType Cat = CheckComparisonCategoryType(
8706 Info.Category, RetLoc, ComparisonCategoryUsage::DefaultedOperator);
8726 diag::err_incorrect_defaulted_comparison_constexpr)
8728 DefaultedComparisonAnalyzer(*
this, RD, FD, DCK,
8729 DefaultedComparisonAnalyzer::ExplainConstexpr)
8750 EPI.ExceptionSpec.SourceDecl = FD;
8752 FPT->getParamTypes(), EPI));
8764 pushCodeSynthesisContext(Ctx);
8766 if (
FunctionDecl *EqualEqual = SubstSpaceshipAsEqualEqual(RD, Spaceship))
8767 EqualEqual->setImplicit();
8769 popCodeSynthesisContext();
8782 Scope.addContextNote(UseLoc);
8789 CXXRecordDecl *RD = PT.getNonReferenceType()->getAsCXXRecordDecl();
8793 DefaultedComparisonSynthesizer(*
this, RD, FD, DCK, BodyLoc).build();
8807 L->CompletedImplicitDefinition(FD);
8814 ComputingExceptionSpec CES(S, FD, Loc);
8835 S, Sema::ExpressionEvaluationContext::Unevaluated);
8841 DefaultedComparisonSynthesizer(S, RD, FD, DCK, BodyLoc).build();
8842 if (!Body.isInvalid())
8855 decltype(DelayedOverridingExceptionSpecChecks) Overriding;
8856 decltype(DelayedEquivalentExceptionSpecChecks)
Equivalent;
8858 std::swap(Overriding, DelayedOverridingExceptionSpecChecks);
8859 std::swap(
Equivalent, DelayedEquivalentExceptionSpecChecks);
8863 for (
auto &Check : Overriding)
8864 CheckOverridingFunctionExceptionSpec(Check.first, Check.second);
8869 CheckEquivalentExceptionSpec(Check.second, Check.first);
8875template<
typename Derived>
8876struct SpecialMemberVisitor {
8883 bool IsConstructor =
false, IsAssignment =
false, ConstArg =
false;
8887 : S(S), MD(MD), CSM(CSM), ICI(ICI) {
8892 IsConstructor =
true;
8896 IsAssignment =
true;
8901 llvm_unreachable(
"invalid special member kind");
8905 if (const ReferenceType *RT =
8906 MD->getParamDecl(0)->getType()->getAs<ReferenceType>())
8907 ConstArg = RT->getPointeeType().isConstQualified();
8911 Derived &getDerived() {
return static_cast<Derived&
>(*this); }
8914 bool isMove()
const {
8920 unsigned Quals,
bool IsMutable) {
8922 ConstArg && !IsMutable);
8939 typedef llvm::PointerUnion<CXXBaseSpecifier*, FieldDecl*> Subobject;
8946 return B->getBaseTypeLoc();
8948 return Subobj.get<
FieldDecl*>()->getLocation();
8953 VisitNonVirtualBases,
8958 VisitPotentiallyConstructedBases,
8964 bool visit(BasesToVisit Bases) {
8967 if (Bases == VisitPotentiallyConstructedBases)
8968 Bases = RD->
isAbstract() ? VisitNonVirtualBases : VisitAllBases;
8970 for (
auto &B : RD->
bases())
8971 if ((Bases == VisitDirectBases || !B.isVirtual()) &&
8972 getDerived().visitBase(&B))
8975 if (Bases == VisitAllBases)
8976 for (
auto &B : RD->
vbases())
8977 if (getDerived().visitBase(&B))
8980 for (
auto *F : RD->
fields())
8981 if (!F->isInvalidDecl() && !F->isUnnamedBitfield() &&
8982 getDerived().visitField(F))
8991struct SpecialMemberDeletionInfo
8992 : SpecialMemberVisitor<SpecialMemberDeletionInfo> {
8997 bool AllFieldsAreConst;
9002 : SpecialMemberVisitor(S, MD, CSM, ICI), Diagnose(Diagnose),
9003 Loc(MD->getLocation()), AllFieldsAreConst(
true) {}
9014 bool visitField(
FieldDecl *Field) {
return shouldDeleteForField(Field); }
9017 bool shouldDeleteForField(
FieldDecl *FD);
9018 bool shouldDeleteForAllConstMembers();
9020 bool shouldDeleteForClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
9022 bool shouldDeleteForSubobjectCall(Subobject Subobj,
9024 bool IsDtorCallInCtor);
9032bool SpecialMemberDeletionInfo::isAccessible(Subobject Subobj,
9053bool SpecialMemberDeletionInfo::shouldDeleteForSubobjectCall(
9055 bool IsDtorCallInCtor) {
9062 DiagKind = !
Decl ? 0 : 1;
9065 else if (!isAccessible(Subobj,
Decl))
9067 else if (!IsDtorCallInCtor && Field &&
Field->getParent()->isUnion() &&
9068 !
Decl->isTrivial()) {
9083 diag::note_deleted_special_member_class_subobject)
9084 << getEffectiveCSM() << MD->
getParent() <<
true
9085 <<
Field << DiagKind << IsDtorCallInCtor <<
false;
9089 diag::note_deleted_special_member_class_subobject)
9090 << getEffectiveCSM() << MD->
getParent() <<
false
9091 <<
Base->getType() << DiagKind << IsDtorCallInCtor
9105bool SpecialMemberDeletionInfo::shouldDeleteForClassSubobject(
9108 bool IsMutable =
Field &&
Field->isMutable();
9125 Field &&
Field->hasInClassInitializer()) &&
9126 shouldDeleteForSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable),
9133 if (IsConstructor) {
9136 false,
false,
false,
false,
false);
9137 if (shouldDeleteForSubobjectCall(Subobj, SMOR,
true))
9144bool SpecialMemberDeletionInfo::shouldDeleteForVariantObjCPtrMember(
9160 diag::note_deleted_special_member_class_subobject)
9161 << getEffectiveCSM() << ParentClass <<
true
9162 << FD << 4 <<
false <<
true;
9179 if (
auto *BaseCtor = SMOR.
getMethod()) {
9184 if (BaseCtor->isDeleted() && Diagnose) {
9186 diag::note_deleted_special_member_class_subobject)
9187 << getEffectiveCSM() << MD->
getParent() <<
false
9188 <<
Base->getType() << 1 <<
false
9192 return BaseCtor->isDeleted();
9194 return shouldDeleteForClassSubobject(BaseClass,
Base, 0);
9199bool SpecialMemberDeletionInfo::shouldDeleteForField(
FieldDecl *FD) {
9203 if (inUnion() && shouldDeleteForVariantObjCPtrMember(FD, FieldType))
9211 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9212 << !!ICI << MD->
getParent() << FD << FieldType << 0;
9222 S.
Diag(FD->
getLocation(), diag::note_deleted_default_ctor_uninit_field)
9228 AllFieldsAreConst =
false;
9234 S.
Diag(FD->
getLocation(), diag::note_deleted_copy_ctor_rvalue_reference)
9238 }
else if (IsAssignment) {
9243 << isMove() << MD->
getParent() << FD << FieldType << 0;
9258 if (!inUnion() && FieldRecord->
isUnion() &&
9260 bool AllVariantFieldsAreConst =
true;
9263 for (
auto *UI : FieldRecord->
fields()) {
9266 if (shouldDeleteForVariantObjCPtrMember(&*UI, UnionFieldType))
9270 AllVariantFieldsAreConst =
false;
9273 if (UnionFieldRecord &&
9274 shouldDeleteForClassSubobject(UnionFieldRecord, UI,
9284 diag::note_deleted_default_ctor_all_const)
9295 if (shouldDeleteForClassSubobject(FieldRecord, FD,
9306bool SpecialMemberDeletionInfo::shouldDeleteForAllConstMembers() {
9310 bool AnyFields =
false;
9312 if ((AnyFields = !F->isUnnamedBitfield()))
9318 diag::note_deleted_default_ctor_all_const)
9344 (CSM == CXXDefaultConstructor || CSM == CXXCopyAssignment)) {
9353 if (CSM != CXXDefaultConstructor && CSM != CXXDestructor &&
9362 (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment)) {
9368 bool DeletesOnlyMatchingCopy =
9369 getLangOpts().MSVCCompat &&
9373 (!DeletesOnlyMatchingCopy || CSM == CXXCopyConstructor)) {
9374 if (!Diagnose)
return true;
9377 for (
auto *I : RD->
ctors()) {
9378 if (I->isMoveConstructor()) {
9379 UserDeclaredMove = I;
9383 assert(UserDeclaredMove);
9385 (!DeletesOnlyMatchingCopy || CSM == CXXCopyAssignment)) {
9386 if (!Diagnose)
return true;
9389 for (
auto *I : RD->
methods()) {
9390 if (I->isMoveAssignmentOperator()) {
9391 UserDeclaredMove = I;
9395 assert(UserDeclaredMove);
9398 if (UserDeclaredMove) {
9400 diag::note_deleted_copy_user_declared_move)
9401 << (CSM == CXXCopyAssignment) << RD
9413 if (CSM == CXXDestructor && MD->
isVirtual()) {
9418 OperatorDelete,
false)) {
9425 SpecialMemberDeletionInfo SMI(*
this, MD, CSM, ICI, Diagnose);
9433 if (SMI.visit(SMI.IsAssignment ? SMI.VisitDirectBases
9434 : SMI.VisitPotentiallyConstructedBases))
9437 if (SMI.shouldDeleteForAllConstMembers())
9440 if (getLangOpts().
CUDA) {
9447 assert(ICI || CSM == getSpecialMember(MD));
9450 RealCSM = getSpecialMember(MD);
9452 return inferCUDATargetForImplicitSpecialMember(RD, RealCSM, MD,
9453 SMI.ConstArg, Diagnose);
9461 assert(DFK &&
"not a defaultable function");
9465 ShouldDeleteSpecialMember(cast<CXXMethodDecl>(FD), DFK.
asSpecialMember(),
9468 DefaultedComparisonAnalyzer(
9470 DFK.
asComparison(), DefaultedComparisonAnalyzer::ExplainDeleted)
9492 *Selected =
nullptr;
9496 llvm_unreachable(
"not a special member");
9514 for (
auto *CI : RD->
ctors()) {
9515 if (!CI->isDefaultConstructor())
9522 *Selected = DefCtor;
9555 }
else if (!Selected) {
9563 goto NeedOverloadResolution;
9573 }
else if (!Selected) {
9578 goto NeedOverloadResolution;
9582 NeedOverloadResolution:
9610 llvm_unreachable(
"unknown special method kind");
9614 for (
auto *CI : RD->
ctors())
9615 if (!CI->isImplicit())
9622 dyn_cast<CXXConstructorDecl>(TI->getTemplatedDecl()))
9652 ConstRHS, TAH, Diagnose ? &Selected :
nullptr))
9660 S.
Diag(SubobjLoc, diag::note_nontrivial_no_def_ctor)
9663 S.
Diag(CD->getLocation(), diag::note_user_declared_ctor);
9664 }
else if (!Selected)
9665 S.
Diag(SubobjLoc, diag::note_nontrivial_no_copy)
9670 << Kind << SubType.getUnqualifiedType() << CSM;
9672 S.
Diag(SubobjLoc, diag::note_nontrivial_user_provided)
9673 << Kind << SubType.getUnqualifiedType() << CSM;
9678 S.
Diag(SubobjLoc, diag::note_nontrivial_subobject)
9679 << Kind << SubType.getUnqualifiedType() << CSM;
9697 for (
const auto *FI : RD->
fields()) {
9698 if (FI->isInvalidDecl() || FI->isUnnamedBitfield())
9704 if (FI->isAnonymousStructOrUnion()) {
9706 CSM, ConstArg, TAH, Diagnose))
9717 S.
Diag(FI->getLocation(), diag::note_nontrivial_default_member_init)
9728 S.
Diag(FI->getLocation(), diag::note_nontrivial_objc_ownership)
9733 bool ConstRHS = ConstArg && !FI->isMutable();
9747 bool ConstArg = (CSM == CXXCopyConstructor || CSM == CXXCopyAssignment);
9758 assert(!MD->
isUserProvided() && CSM != CXXInvalid &&
"not special enough");
9762 bool ConstArg =
false;
9768 case CXXDefaultConstructor:
9773 case CXXCopyConstructor:
9774 case CXXCopyAssignment: {
9786 const bool ClangABICompat14 = Context.
getLangOpts().getClangABICompat() <=
9787 LangOptions::ClangABI::Ver14;
9790 ClangABICompat14)) {
9803 case CXXMoveConstructor:
9804 case CXXMoveAssignment: {
9820 llvm_unreachable(
"not a special member");
9826 diag::note_nontrivial_default_arg)
9845 for (
const auto &BI : RD->
bases())
9868 if (CSM == CXXDestructor && MD->
isVirtual()) {
9891 for (
const auto *MI : RD->
methods()) {
9892 if (MI->isVirtual()) {
9894 Diag(MLoc, diag::note_nontrivial_has_virtual) << RD << 0;
9899 llvm_unreachable(
"dynamic class with no vbases and no virtual functions");
9907struct FindHiddenVirtualMethod {
9915 static bool CheckMostOverridenMethods(
9917 const llvm::SmallPtrSetImpl<const CXXMethodDecl *> &Methods) {
9921 if (CheckMostOverridenMethods(O, Methods))
9932 Specifier->getType()->castAs<
RecordType>()->getDecl();
9937 bool foundSameNameMethod =
false;
9944 foundSameNameMethod =
true;
9961 if (!CheckMostOverridenMethods(MD, OverridenAndUsingBaseMethods))
9962 overloadedMethods.push_back(MD);
9966 if (foundSameNameMethod)
9967 OverloadedMethods.append(overloadedMethods.begin(),
9968 overloadedMethods.end());
9969 return foundSameNameMethod;
9976 llvm::SmallPtrSetImpl<const CXXMethodDecl *>& Methods) {
9994 FindHiddenVirtualMethod FHVM;
10005 ND = shad->getTargetDecl();
10011 OverloadedMethods = FHVM.OverloadedMethods;
10016 for (
unsigned i = 0, e = OverloadedMethods.size(); i != e; ++i) {
10019 diag::note_hidden_overloaded_virtual_declared_here) << overloadedMD;
10020 HandleFunctionTypeMismatch(PD, MD->
getType(), overloadedMD->
getType());
10031 if (Diags.isIgnored(diag::warn_overloaded_virtual, MD->
getLocation()))
10035 FindHiddenVirtualMethods(MD, OverloadedMethods);
10036 if (!OverloadedMethods.empty()) {
10038 << MD << (OverloadedMethods.size() > 1);
10040 NoteHiddenVirtualMethods(MD, OverloadedMethods);
10045 auto PrintDiagAndRemoveAttr = [&](
unsigned N) {
10048 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10049 diag::ext_cannot_use_trivial_abi) << &RD;
10050 Diag(RD.
getAttr<TrivialABIAttr>()->getLocation(),
10051 diag::note_cannot_use_trivial_abi_reason) << &RD <<
N;
10057 auto HasNonDeletedCopyOrMoveConstructor = [&]() {
10069 if (CD->isCopyOrMoveConstructor() && !CD->isDeleted())
10074 if (!HasNonDeletedCopyOrMoveConstructor()) {
10075 PrintDiagAndRemoveAttr(0);
10081 PrintDiagAndRemoveAttr(1);
10085 for (
const auto &B : RD.
bases()) {
10088 if (!B.getType()->isDependentType() &&
10089 !B.getType()->getAsCXXRecordDecl()->canPassInRegisters()) {
10090 PrintDiagAndRemoveAttr(2);
10094 if (B.isVirtual()) {
10095 PrintDiagAndRemoveAttr(3);
10100 for (
const auto *FD : RD.
fields()) {
10105 PrintDiagAndRemoveAttr(4);
10110 if (!RT->isDependentType() &&
10111 !cast<CXXRecordDecl>(RT->getDecl())->canPassInRegisters()) {
10112 PrintDiagAndRemoveAttr(5);
10124 AdjustDeclIfTemplate(
TagDecl);
10127 if (AL.getKind() != ParsedAttr::AT_Visibility)
10130 Diag(AL.getLoc(), diag::warn_attribute_after_definition_ignored) << AL;
10133 ActOnFields(S, RLoc,
TagDecl, llvm::makeArrayRef(
10135 reinterpret_cast<Decl**
>(FieldCollector->getCurFields()),
10136 FieldCollector->getCurNumFields()), LBrac, RBrac, AttrList);
10138 CheckCompletedCXXClass(S, cast<CXXRecordDecl>(
TagDecl));
10153 FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Friend->getFriendDecl());
10158 Spaceships.clear();
10164 Spaceships.push_back(FD);
10173 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
10174 if (FD->isExplicitlyDefaulted())
10175 Spaceships.push_back(FD);
10190 ++getASTContext().NumImplicitDefaultConstructors;
10193 DeclareImplicitDefaultConstructor(ClassDecl);
10197 ++getASTContext().NumImplicitCopyConstructors;
10204 DeclareImplicitCopyConstructor(ClassDecl);
10215 DeclareImplicitCopyConstructor(ClassDecl);
10220 ++getASTContext().NumImplicitMoveConstructors;
10224 DeclareImplicitMoveConstructor(ClassDecl);
10228 ++getASTContext().NumImplicitCopyAssignmentOperators;
10237 DeclareImplicitCopyAssignment(ClassDecl);
10241 ++getASTContext().NumImplicitMoveAssignmentOperators;
10247 DeclareImplicitMoveAssignment(ClassDecl);
10251 ++getASTContext().NumImplicitDestructors;
10259 DeclareImplicitDestructor(ClassDecl);
10272 if (getLangOpts().
CPlusPlus20 && !inTemplateInstantiation()) {
10275 DefaultedSpaceships);
10276 for (
auto *FD : DefaultedSpaceships)
10277 DeclareImplicitEqualityComparison(ClassDecl, FD);
10283 llvm::function_ref<
Scope *()> EnterScope) {
10286 AdjustDeclIfTemplate(D);
10291 DeclContext *LookupDC = dyn_cast<DeclContext>(D);
10294 for (
unsigned i = 0; i < DD->getNumTemplateParameterLists(); ++i)
10295 ParameterLists.push_back(DD->getTemplateParameterList(i));
10299 ParameterLists.push_back(FTD->getTemplateParameters());
10300 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(D)) {
10304 ParameterLists.push_back(VTD->getTemplateParameters());
10305 else if (
auto *PSD = dyn_cast<VarTemplatePartialSpecializationDecl>(D))
10306 ParameterLists.push_back(PSD->getTemplateParameters());
10308 }
else if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
10309 for (
unsigned i = 0; i < TD->getNumTemplateParameterLists(); ++i)
10310 ParameterLists.push_back(TD->getTemplateParameterList(i));
10314 ParameterLists.push_back(CTD->getTemplateParameters());
10315 else if (
auto *PSD = dyn_cast<ClassTemplatePartialSpecializationDecl>(D))
10316 ParameterLists.push_back(PSD->getTemplateParameters());
10321 unsigned Count = 0;
10322 Scope *InnermostTemplateScope =
nullptr;
10326 if (Params->size() == 0)
10329 InnermostTemplateScope = EnterScope();
10331 if (Param->getDeclName()) {
10332 InnermostTemplateScope->
AddDecl(Param);
10333 IdResolver.AddDecl(Param);
10340 if (InnermostTemplateScope) {
10341 assert(LookupDC &&
"no enclosing DeclContext for template lookup");
10342 EnterTemplatedContext(InnermostTemplateScope, LookupDC);
10349 if (!RecordD)
return;
10350 AdjustDeclIfTemplate(RecordD);
10352 PushDeclContext(S, Record);
10356 if (!RecordD)
return;
10368 if (Param->getDeclName())
10369 IdResolver.AddDecl(Param);
10395 if (Param->getDeclName())
10396 IdResolver.AddDecl(Param);
10409 AdjustDeclIfTemplate(MethodD);
10418 CheckConstructor(Constructor);
10421 if (!Method->isInvalidDecl())
10422 CheckCXXDefaultArguments(Method);
10430 bool DiagOccured =
false;
10432 [DiagID, &S, &DiagOccured](
DeclSpec::TQ, StringRef QualName,
10439 DiagOccured =
true;
10478 diagnoseIgnoredQualifiers(
10517 = dyn_cast<CXXRecordDecl>(Constructor->getDeclContext());
10519 return Constructor->setInvalidDecl();
10526 if (!Constructor->isInvalidDecl() &&
10527 Constructor->hasOneParamOrDefaultArgs() &&
10528 Constructor->getTemplateSpecializationKind() !=
10530 QualType ParamType = Constructor->getParamDecl(0)->getType();
10533 SourceLocation ParamLoc = Constructor->getParamDecl(0)->getLocation();
10534 const char *ConstRef
10535 = Constructor->getParamDecl(0)->getIdentifier() ?
"const &"
10537 Diag(ParamLoc, diag::err_constructor_byvalue_arg)
10542 Constructor->setInvalidDecl();
10553 if (!Destructor->getOperatorDelete() && Destructor->isVirtual()) {
10556 if (!Destructor->isImplicit())
10557 Loc = Destructor->getLocation();
10563 FindDeallocationFunctionForDestructor(Loc, RD)) {
10564 Expr *ThisArg =
nullptr;
10569 if (OperatorDelete->isDestroyingOperatorDelete()) {
10570 QualType ParamType = OperatorDelete->getParamDecl(0)->getType();
10577 ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
10578 assert(!This.isInvalid() &&
"couldn't form 'this' expr in dtor?");
10579 This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
10580 if (This.isInvalid()) {
10583 Diag(Loc, diag::note_implicit_delete_this_in_destructor_here);
10586 ThisArg = This.get();
10590 DiagnoseUseOfDecl(OperatorDelete, Loc);
10591 MarkFunctionReferenced(Loc, OperatorDelete);
10592 Destructor->setOperatorDelete(OperatorDelete, ThisArg);
10615 << DeclaratorType << isa<TypeAliasDecl>(TT->getDecl());
10618 if (TST->isTypeAlias())
10620 << DeclaratorType << 1;
10653 diagnoseIgnoredQualifiers(diag::err_destructor_return_type, TypeQuals,
10714 if (After.isInvalid())
10718 R.
setEnd(After.getEnd());
10774 if (Proto->getNumParams() > 0) {
10780 }
else if (Proto->isVariadic()) {
10787 if (Proto->getReturnType() != ConvType) {
10788 bool NeedsTypedef =
false;
10792 bool PastFunctionChunk =
false;
10794 switch (Chunk.Kind) {
10796 if (!PastFunctionChunk) {
10797 if (Chunk.Fun.HasTrailingReturnType) {
10799 GetTypeFromParser(Chunk.Fun.getTrailingReturnType(), &TRT);
10802 PastFunctionChunk =
true;
10807 NeedsTypedef =
true;
10827 After.isValid() ? After.getBegin() :
10829 auto &&DB =
Diag(Loc, diag::err_conv_function_with_complex_decl);
10830 DB << Before << After;
10832 if (!NeedsTypedef) {
10836 if (After.isInvalid() && ConvTSI) {
10844 }
else if (!Proto->getReturnType()->isDependentType()) {
10845 DB << 1 << Proto->getReturnType();
10847 DB << 2 << Proto->getReturnType();
10858 ConvType = Proto->getReturnType();
10878 R = Context.
getFunctionType(ConvType, None, Proto->getExtProtoInfo());
10884 ? diag::warn_cxx98_compat_explicit_conversion_functions
10885 : diag::ext_explicit_conversion_functions)
10894 assert(Conversion &&
"Expected to receive a conversion function declaration");
10917 if (ConvType == ClassType)
10920 else if (IsDerivedFrom(Conversion->
getLocation(), ClassType, ConvType))
10922 << ClassType << ConvType;
10925 << ClassType << ConvType;
10930 return ConversionTemplate;
10938struct BadSpecifierDiagnoser {
10941 ~BadSpecifierDiagnoser() {
10945 template<
typename T>
void check(
SourceLocation SpecLoc, T Spec) {
10949 return check(SpecLoc,
10955 if (!Specifiers.empty()) Specifiers +=
" ";
10956 Specifiers += Spec;
10961 std::string Specifiers;
10973 assert(GuidedTemplateDecl &&
"missing template decl for deduction guide");
10978 if (!CurContext->getRedeclContext()->Equals(
10981 << GuidedTemplateDecl;
10982 Diag(GuidedTemplateDecl->
getLocation(), diag::note_template_decl_here);
10987 if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
10988 DS.getStorageClassSpecLoc().isValid() || DS.isInlineSpecified() ||
10989 DS.isNoreturnSpecified() || DS.hasConstexprSpecifier()) {
10990 BadSpecifierDiagnoser Diagnoser(
10992 diag::err_deduction_guide_invalid_specifier);
10994 Diagnoser.check(DS.getStorageClassSpecLoc(), DS.getStorageClassSpec());
10995 DS.ClearStorageClassSpecs();
10999 Diagnoser.check(DS.getInlineSpecLoc(),
"inline");
11000 Diagnoser.check(DS.getNoreturnSpecLoc(),
"_Noreturn");
11001 Diagnoser.check(DS.getConstexprSpecLoc(),
"constexpr");
11002 DS.ClearConstexprSpec();
11004 Diagnoser.check(DS.getConstSpecLoc(),
"const");
11005 Diagnoser.check(DS.getRestrictSpecLoc(),
"__restrict");
11006 Diagnoser.check(DS.getVolatileSpecLoc(),
"volatile");
11007 Diagnoser.check(DS.getAtomicSpecLoc(),
"_Atomic");
11008 Diagnoser.check(DS.getUnalignedSpecLoc(),
"__unaligned");
11009 DS.ClearTypeQualifiers();
11011 Diagnoser.check(DS.getTypeSpecComplexLoc(), DS.getTypeSpecComplex());
11012 Diagnoser.check(DS.getTypeSpecSignLoc(), DS.getTypeSpecSign());
11013 Diagnoser.check(DS.getTypeSpecWidthLoc(), DS.getTypeSpecWidth());
11014 Diagnoser.check(DS.getTypeSpecTypeLoc(), DS.getTypeSpecType());
11015 DS.ClearTypeSpecType();
11022 bool FoundFunction =
false;
11028 diag::err_deduction_guide_with_complex_decl)
11032 if (!Chunk.Fun.hasTrailingReturnType()) {
11034 diag::err_deduction_guide_no_trailing_return_type);
11040 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
11042 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
11043 assert(TSI &&
"deduction guide has valid type but invalid return type?");
11044 bool AcceptableReturnType =
false;
11045 bool MightInstantiateToSpecialization =
false;
11048 TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
11049 bool TemplateMatches =
11054 AcceptableReturnType =
true;
11063 MightInstantiateToSpecialization =
true;
11066 if (!AcceptableReturnType) {
11068 diag::err_deduction_guide_bad_trailing_return_type)
11069 << GuidedTemplate << TSI->
getType()
11070 << MightInstantiateToSpecialization
11076 FoundFunction =
true;
11093 assert(*IsInline != PrevNS->
isInline());
11103 S.
Diag(Loc, diag::warn_inline_namespace_reopened_noninline)
11106 S.
Diag(Loc, diag::err_inline_namespace_mismatch);
11121 bool IsInline = InlineLoc.
isValid();
11122 bool IsInvalid =
false;
11123 bool IsStd =
false;
11124 bool AddToKnown =
false;
11140 LookupResult R(*
this, II, IdentLoc, LookupOrdinaryName,
11141 ForExternalRedeclaration);
11142 LookupQualifiedName(R, CurContext->getRedeclContext());
11145 PrevNS = dyn_cast_or_null<NamespaceDecl>(PrevDecl);
11149 if (IsInline != PrevNS->
isInline())
11151 &IsInline, PrevNS);
11152 }
else if (PrevDecl) {
11154 Diag(Loc, diag::err_redefinition_different_kind)
11159 }
else if (II->
isStr(
"std") &&
11160 CurContext->getRedeclContext()->isTranslationUnit()) {
11163 PrevNS = getStdNamespace();
11165 AddToKnown = !IsInline;
11168 AddToKnown = !IsInline;
11182 if (PrevNS && IsInline != PrevNS->
isInline())
11184 &IsInline, PrevNS);
11188 StartLoc, Loc, II, PrevNS);
11192 ProcessDeclAttributeList(DeclRegionScope, Namespc, AttrList);
11193 AddPragmaAttributes(DeclRegionScope, Namespc);
11196 if (
const VisibilityAttr *
Attr = Namespc->
getAttr<VisibilityAttr>())
11197 PushNamespaceVisibilityAttr(
Attr, Loc);
11200 StdNamespace = Namespc;
11202 KnownNamespaces[Namespc] =
false;
11205 PushOnScopeChains(Namespc, DeclRegionScope);
11210 TU->setAnonymousNamespace(Namespc);
11215 CurContext->
addDecl(Namespc);
11246 ActOnDocumentableDecl(Namespc);
11253 PushDeclContext(NamespcScope, Namespc);
11261 return AD->getNamespace();
11262 return dyn_cast_or_null<NamespaceDecl>(D);
11268 NamespaceDecl *Namespc = dyn_cast_or_null<NamespaceDecl>(Dcl);
11269 assert(Namespc &&
"Invalid parameter, expected NamespaceDecl");
11272 if (Namespc->
hasAttr<VisibilityAttr>())
11273 PopPragmaVisibility(
true, RBrace);
11275 if (DeferredExportedNamespaces.erase(Namespc))
11280 return cast_or_null<CXXRecordDecl>(
11289 return cast_or_null<NamespaceDecl>(
11294 if (!StdExperimentalNamespaceCache) {
11295 if (
auto Std = getStdNamespace()) {
11296 LookupResult Result(*
this, &PP.getIdentifierTable().get(
"experimental"),
11298 if (!LookupQualifiedName(Result,
Std) ||
11299 !(StdExperimentalNamespaceCache =
11301 Result.suppressDiagnostics();
11304 return StdExperimentalNamespaceCache;
11309enum UnsupportedSTLSelect {
11316struct InvalidSTLDiagnoser {
11321 QualType operator()(UnsupportedSTLSelect Sel = USS_Other, StringRef Name =
"",
11322 const VarDecl *VD =
nullptr) {
11324 auto D = S.
Diag(Loc, diag::err_std_compare_type_not_supported)
11325 << TyForDiags << ((
int)Sel);
11326 if (Sel == USS_InvalidMember || Sel == USS_MissingMember) {
11327 assert(!Name.empty());
11331 if (Sel == USS_InvalidMember) {
11344 "Looking for comparison category type outside of C++.");
11357 if (Info && FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)]) {
11360 if (RequireCompleteType(Loc, TyForDiags(Info), diag::err_incomplete_type))
11368 std::string NameForDiags =
"std::";
11370 Diag(Loc, diag::err_implied_comparison_category_type_not_found)
11371 << NameForDiags << (
int)Usage;
11375 assert(Info->
Kind == Kind);
11383 if (RequireCompleteType(Loc, TyForDiags(Info), diag::err_incomplete_type))
11386 InvalidSTLDiagnoser UnsupportedSTLError{*
this, Loc, TyForDiags(Info)};
11389 return UnsupportedSTLError(USS_NonTrivial);
11394 if (
Base->isEmpty())
11397 return UnsupportedSTLError();
11405 if (std::distance(FIt, FEnd) != 1 ||
11406 !FIt->getType()->isIntegralOrEnumerationType()) {
11407 return UnsupportedSTLError();
11417 return UnsupportedSTLError(USS_MissingMember, MemName);
11420 assert(VD &&
"should not be null!");
11427 return UnsupportedSTLError(USS_InvalidMember, MemName, VD);
11433 return UnsupportedSTLError();
11435 MarkVariableReferenced(Loc, VD);
11440 FullyCheckedComparisonCategories[
static_cast<unsigned>(Kind)] =
true;
11447 if (!StdNamespace) {
11453 &PP.getIdentifierTable().get(
"std"),
11455 getStdNamespace()->setImplicit(
true);
11458 return getStdNamespace();
11463 "Looking for std::initializer_list outside of C++.");
11477 dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl());
11485 Template = dyn_cast_or_null<ClassTemplateDecl>(
11486 TST->getTemplateName().getAsTemplateDecl());
11487 Arguments = TST->getArgs();
11492 if (!StdInitializerList) {
11496 &PP.getIdentifierTable().get(
"initializer_list") ||
11497 !getStdNamespace()->InEnclosingNamespaceSetOf(
11505 if (!isa<TemplateTypeParmDecl>(Params->
getParam(0)))
11509 StdInitializerList = Template;
11517 *Element = Arguments[0].getAsType();
11524 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
11531 S.
Diag(Loc, diag::err_implied_std_initializer_list_not_found);
11536 Result.suppressDiagnostics();
11539 S.
Diag(Found->
getLocation(), diag::err_malformed_std_initializer_list);
11547 !isa<TemplateTypeParmDecl>(Params->
getParam(0))) {
11548 S.
Diag(Template->
getLocation(), diag::err_malformed_std_initializer_list);
11556 if (!StdInitializerList) {
11558 if (!StdInitializerList)
11567 CheckTemplateIdType(
TemplateName(StdInitializerList), Loc, Args));
11583 return isStdInitializerList(ArgType,
nullptr);
11590 case Decl::TranslationUnit:
11592 case Decl::LinkageSpec:
11604 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
11610 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
11611 return std::make_unique<NamespaceValidatorCCC>(*
this);
11622 NamespaceValidatorCCC CCC{};
11627 std::string CorrectedStr(Corrected.getAsString(S.
getLangOpts()));
11628 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
11629 Ident->
getName().equals(CorrectedStr);
11631 S.
PDiag(diag::err_using_directive_member_suggest)
11632 << Ident << DC << DroppedSpecifier << SS.
getRange(),
11633 S.
PDiag(diag::note_namespace_defined_here));
11636 S.
PDiag(diag::err_using_directive_suggest) << Ident,
11637 S.
PDiag(diag::note_namespace_defined_here));
11639 R.
addDecl(Corrected.getFoundDecl());
11650 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
11651 assert(NamespcName &&
"Invalid NamespcName.");
11652 assert(IdentLoc.
isValid() &&
"Invalid NamespceName location.");
11655 while (S->isTemplateParamScope())
11656 S = S->getParent();
11665 LookupResult R(*
this, NamespcName, IdentLoc, LookupNamespaceName);
11666 LookupParsedName(R, S, &SS);
11675 NamespcName->
isStr(
"std")) {
11676 Diag(IdentLoc, diag::ext_using_undefined_std);
11677 R.
addDecl(getOrCreateStdNamespace());
11687 assert(NS &&
"expected namespace decl");
11690 DiagnoseUseOfDecl(Named, IdentLoc);
11705 while (CommonAncestor && !CommonAncestor->
Encloses(CurContext))
11706 CommonAncestor = CommonAncestor->
getParent();
11710 IdentLoc, Named, CommonAncestor);
11713 !SourceMgr.isInMainFile(SourceMgr.getExpansionLoc(IdentLoc))) {
11714 Diag(IdentLoc, diag::warn_using_directive_in_header);
11717 PushUsingDirective(S, UDir);
11719 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
11723 ProcessDeclAttributeList(S, UDir, AttrList);
11750 Diag(Name.getBeginLoc(), diag::err_using_requires_qualname);
11754 switch (Name.getKind()) {
11755 case UnqualifiedIdKind::IK_ImplicitSelfParam:
11756 case UnqualifiedIdKind::IK_Identifier:
11757 case UnqualifiedIdKind::IK_OperatorFunctionId:
11758 case UnqualifiedIdKind::IK_LiteralOperatorId:
11759 case UnqualifiedIdKind::IK_ConversionFunctionId:
11762 case UnqualifiedIdKind::IK_ConstructorName:
11763 case UnqualifiedIdKind::IK_ConstructorTemplateId:
11765 Diag(Name.getBeginLoc(),
11767 ? diag::warn_cxx98_compat_using_decl_constructor
11768 : diag::err_using_decl_constructor)
11775 case UnqualifiedIdKind::IK_DestructorName:
11776 Diag(Name.getBeginLoc(), diag::err_using_decl_destructor) << SS.
getRange();
11779 case UnqualifiedIdKind::IK_TemplateId:
11780 Diag(Name.getBeginLoc(), diag::err_using_decl_template_id)
11781 <<
SourceRange(Name.TemplateId->LAngleLoc, Name.TemplateId->RAngleLoc);
11784 case UnqualifiedIdKind::IK_DeductionGuideName:
11785 llvm_unreachable(
"cannot parse qualified deduction guide name");
11796 ? diag::err_access_decl
11797 : diag::warn_access_decl_deprecated)
11802 if (DiagnoseUnexpandedParameterPack(SS, UPPC_UsingDeclaration) ||
11803 DiagnoseUnexpandedParameterPack(TargetNameInfo, UPPC_UsingDeclaration))
11808 Diag(EllipsisLoc, diag::err_pack_expansion_without_parameter_packs)
11815 BuildUsingDeclaration(S, AS, UsingLoc, TypenameLoc.
isValid(), TypenameLoc,
11816 SS, TargetNameInfo, EllipsisLoc, AttrList,
11820 PushOnScopeChains(UD, S,
false);
11842 llvm_unreachable(
"unexpected DeclSpec type");
11847 if (
auto *Def =
Enum->getDefinition())
11850 auto *UD = BuildUsingEnumDeclaration(S, AS, UsingLoc, EnumLoc,
11853 PushOnScopeChains(UD, S,
false);
11868 return Context.
hasSameType(TD1->getUnderlyingType(),
11869 TD2->getUnderlyingType());
11873 if (isa<UnresolvedUsingIfExistsDecl>(D1) &&
11874 isa<UnresolvedUsingIfExistsDecl>(D2))
11905 if (!getLangOpts().
CPlusPlus11 && CurContext->isRecord())
11906 if (
auto *Using = dyn_cast<UsingDecl>(BUD)) {
11910 if (isa<EnumDecl>(OrigDC))
11917 if (OrigDC == CurContext) {
11918 Diag(Using->getLocation(),
11919 diag::err_using_decl_nested_name_specifier_is_current_class)
11920 << Using->getQualifierLoc().getSourceRange();
11922 Using->setInvalidDecl();
11926 Diag(Using->getQualifierLoc().getBeginLoc(),
11927 diag::err_using_decl_nested_name_specifier_is_not_base_class)
11929 << Using->getQualifierLoc().getSourceRange();
11931 Using->setInvalidDecl();
11936 if (
Previous.empty())
return false;
11939 if (isa<UsingShadowDecl>(Target))
11947 NamedDecl *NonTag =
nullptr, *Tag =
nullptr;
11948 bool FoundEquivalentDecl =
false;
11951 NamedDecl *D = (*I)->getUnderlyingDecl();
11955 if (isa<UsingDecl>(D) || isa<UsingPackDecl>(D) || isa<UsingEnumDecl>(D))
11958 if (
auto *RD = dyn_cast<CXXRecordDecl>(D)) {
11963 !isa<IndirectFieldDecl>(Target) &&
11964 !isa<UnresolvedUsingValueDecl>(Target) &&
11965 DiagnoseClassNameShadow(
11973 PrevShadow = Shadow;
11974 FoundEquivalentDecl =
true;
11975 }
else if (isEquivalentInternalLinkageDeclaration(D, Target)) {
11978 FoundEquivalentDecl =
true;
11985 if (FoundEquivalentDecl)
11990 if (isa<UnresolvedUsingIfExistsDecl>(Target) !=
11991 (isa_and_nonnull<UnresolvedUsingIfExistsDecl>(NonTag))) {
11992 if (!NonTag && !Tag)
11995 Diag(Target->getLocation(), diag::note_using_decl_target);
11996 Diag((NonTag ? NonTag : Tag)->getLocation(),
11997 diag::note_using_decl_conflict);
12004 switch (CheckOverload(
nullptr, FD,
Previous, OldDecl,
12009 case Ovl_NonFunction:
12018 if (CurContext->isRecord())
12026 Diag(Target->getLocation(), diag::note_using_decl_target);
12034 if (isa<TagDecl>(Target)) {
12036 if (!Tag)
return false;
12039 Diag(Target->getLocation(), diag::note_using_decl_target);
12040 Diag(Tag->getLocation(), diag::note_using_decl_conflict);
12046 if (!NonTag)
return false;
12049 Diag(Target->getLocation(), diag::note_using_decl_target);
12059 for (
auto &B : Derived->
bases())
12060 if (B.getType()->getAsCXXRecordDecl() ==
Base)
12061 return B.isVirtual();
12062 llvm_unreachable(
"not a direct base class");
12071 if (isa<UsingShadowDecl>(Target)) {
12073 assert(!isa<UsingShadowDecl>(Target) &&
"nested shadow declaration");
12077 if (
auto *TargetTD = dyn_cast<TemplateDecl>(Target))
12078 NonTemplateTarget = TargetTD->getTemplatedDecl();
12081 if (NonTemplateTarget && isa<CXXConstructorDecl>(NonTemplateTarget)) {
12083 bool IsVirtualBase =
12085 Using->getQualifier()->getAsRecordDecl());
12087 Context, CurContext, Using->getLocation(), Using, Orig, IsVirtualBase);
12090 Target->getDeclName(), BUD, Target);
12101 PushOnScopeChains(Shadow, S);
12103 CurContext->addDecl(Shadow);
12146 S->RemoveDecl(Shadow);
12147 IdResolver.RemoveDecl(Shadow);
12160 bool &AnyDependentBases) {
12165 CanQualType BaseType =
Base.getType()->getCanonicalTypeUnqualified();
12166 if (CanonicalDesiredBase == BaseType)
12168 if (BaseType->isDependentType())
12169 AnyDependentBases =
true;
12177 UsingValidatorCCC(
bool HasTypenameKeyword,
bool IsInstantiation,
12179 : HasTypenameKeyword(HasTypenameKeyword),
12180 IsInstantiation(IsInstantiation), OldNNS(NNS),
12181 RequireMemberOf(RequireMemberOf) {}
12183 bool ValidateCandidate(
const TypoCorrection &Candidate)
override {
12187 if (!ND || isa<NamespaceDecl>(ND))
12197 if (RequireMemberOf) {
12198 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12199 if (FoundRecord && FoundRecord->isInjectedClassName()) {
12214 if (!Specifier->getAsType() ||
12220 bool AnyDependentBases =
false;
12223 AnyDependentBases) &&
12224 !AnyDependentBases)
12234 auto *FoundRecord = dyn_cast<CXXRecordDecl>(ND);
12235 if (FoundRecord && FoundRecord->isInjectedClassName())
12239 if (isa<TypeDecl>(ND))
12240 return HasTypenameKeyword || !IsInstantiation;
12242 return !HasTypenameKeyword;
12245 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
12246 return std::make_unique<UsingValidatorCCC>(*
this);
12250 bool HasTypenameKeyword;
12251 bool IsInstantiation;
12267 if (!isDeclInScope(D, CurContext, S))
12290 bool IsUsingIfExists) {
12291 assert(!SS.
isInvalid() &&
"Invalid CXXScopeSpec.");
12293 assert(IdentLoc.
isValid() &&
"Invalid TargetName location.");
12302 if (
auto *RD = dyn_cast<CXXRecordDecl>(CurContext))
12308 ForVisibleRedeclaration);
12315 assert(IsInstantiation &&
"no scope in non-instantiation");
12316 if (CurContext->isRecord())
12317 LookupQualifiedName(
Previous, CurContext);
12336 if (CheckUsingDeclRedeclaration(UsingLoc, HasTypenameKeyword,
12343 Diag(UsingLoc, diag::err_using_if_exists_on_ctor);
12347 DeclContext *LookupContext = computeDeclContext(SS);
12349 if (!LookupContext || EllipsisLoc.
isValid()) {
12352 if (!LookupContext && CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword,
12353 SS, NameInfo, IdentLoc))
12356 if (HasTypenameKeyword) {
12359 UsingLoc, TypenameLoc,
12361 IdentLoc, NameInfo.
getName(),
12365 QualifierLoc, NameInfo, EllipsisLoc);
12368 CurContext->addDecl(D);
12369 ProcessDeclAttributeList(S, D, AttrList);
12373 auto Build = [&](
bool Invalid) {
12376 UsingName, HasTypenameKeyword);
12378 CurContext->addDecl(UD);
12379 ProcessDeclAttributeList(S, UD, AttrList);
12383 auto BuildInvalid = [&]{
return Build(
true); };
12384 auto BuildValid = [&]{
return Build(
false); };
12386 if (RequireCompleteDeclContext(SS, LookupContext))
12387 return BuildInvalid();
12396 if (!IsInstantiation)
12401 if (CurContext->isRecord()) {
12406 LookupQualifiedName(R, LookupContext);
12409 if (CheckUsingDeclQualifier(UsingLoc, HasTypenameKeyword, SS, NameInfo,
12413 if (R.
empty() && IsUsingIfExists)
12428 if (getLangOpts().
CPlusPlus14 && II && II->isStr(
"gets") &&
12429 CurContext->isStdNamespace() &&
12430 isa<TranslationUnitDecl>(LookupContext) &&
12431 getSourceManager().isInSystemHeader(UsingLoc))
12433 UsingValidatorCCC CCC(HasTypenameKeyword, IsInstantiation, SS.
getScopeRep(),
12434 dyn_cast<CXXRecordDecl>(CurContext));
12437 CTK_ErrorRecovery)) {
12440 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
12441 << NameInfo.
getName() << LookupContext << 0
12446 NamedDecl *ND = Corrected.getCorrectionDecl();
12448 return BuildInvalid();
12451 auto *RD = dyn_cast<CXXRecordDecl>(ND);
12457 if (Corrected.WillReplaceSpecifier()) {
12459 Builder.
MakeTrivial(Context, Corrected.getCorrectionSpecifier(),
12461 QualifierLoc = Builder.getWithLocInContext(Context);
12470 for (
auto *Ctor : LookupConstructors(RD))
12480 Diag(IdentLoc, diag::err_no_member)
12482 return BuildInvalid();
12487 return BuildInvalid();
12489 if (HasTypenameKeyword) {
12493 Diag(IdentLoc, diag::err_using_typename_non_type);
12495 Diag((*I)->getUnderlyingDecl()->getLocation(),
12496 diag::note_using_decl_target);
12497 return BuildInvalid();
12504 Diag(IdentLoc, diag::err_using_dependent_value_is_type);
12506 return BuildInvalid();
12513 Diag(IdentLoc, diag::err_using_decl_can_not_refer_to_namespace)
12515 return BuildInvalid();
12526 if (CheckInheritingConstructorUsingDecl(UD))
12532 if (!CheckUsingShadowDecl(UD, *I,
Previous, PrevDecl))
12533 BuildUsingShadowDecl(S, UD, *I, PrevDecl);
12546 if (CurContext->getRedeclContext()->isRecord()) {
12550 ForVisibleRedeclaration);
12556 if (UED->getEnumDecl() == ED) {
12557 Diag(UsingLoc, diag::err_using_enum_decl_redeclaration)
12565 if (RequireCompleteEnumDecl(ED, NameLoc))
12569 EnumLoc, NameLoc, ED);
12571 CurContext->addDecl(UD);
12583 ForVisibleRedeclaration);
12587 if (!CheckUsingShadowDecl(UD, EC,
Previous, PrevDecl))
12588 BuildUsingShadowDecl(S, UD, EC, PrevDecl);
12596 assert(isa<UnresolvedUsingValueDecl>(InstantiatedFrom) ||
12597 isa<UnresolvedUsingTypenameDecl>(InstantiatedFrom) ||
12598 isa<UsingPackDecl>(InstantiatedFrom));
12602 UPD->setAccess(InstantiatedFrom->
getAccess());
12603 CurContext->addDecl(UPD);
12609 assert(!UD->
hasTypename() &&
"expecting a constructor name");
12612 assert(SourceType &&
12613 "Using decl naming constructor doesn't have type in scope spec.");
12617 bool AnyDependentBases =
false;
12619 AnyDependentBases);
12620 if (!
Base && !AnyDependentBases) {
12622 diag::err_using_decl_constructor_not_in_direct_base)
12624 <<
QualType(SourceType, 0) << TargetClass;
12630 Base->setInheritConstructors();
12639 bool HasTypenameKeyword,
12652 if (!CurContext->getRedeclContext()->isRecord()) {
12658 if (Qual->
isDependent() && !HasTypenameKeyword) {
12659 for (
auto *D : Prev) {
12660 if (!isa<TypeDecl>(D) && !isa<UsingDecl>(D) && !isa<UsingPackDecl>(D)) {
12661 bool OldCouldBeEnumerator =
12664 OldCouldBeEnumerator ? diag::err_redefinition
12665 : diag::err_redefinition_different_kind)
12666 << Prev.getLookupName();
12682 if (
UsingDecl *UD = dyn_cast<UsingDecl>(D)) {
12683 DTypename = UD->hasTypename();
12684 DQual = UD->getQualifier();
12686 = dyn_cast<UnresolvedUsingValueDecl>(D)) {
12688 DQual = UD->getQualifier();
12690 = dyn_cast<UnresolvedUsingTypenameDecl>(D)) {
12692 DQual = UD->getQualifier();
12697 if (HasTypenameKeyword != DTypename)
continue;
12705 Diag(NameLoc, diag::err_using_decl_redeclaration) << SS.
getRange();
12725 DeclContext *NamedContext = computeDeclContext(SS);
12726 assert(
bool(NamedContext) == (R || UD) && !(R && UD) &&
12727 "resolvable context must have exactly one set of decls");
12731 bool Cxx20Enumerator =
false;
12732 if (NamedContext) {
12739 Cxx20Enumerator = getLangOpts().CPlusPlus20;
12741 if (
auto *ED = dyn_cast<EnumDecl>(NamedContext)) {
12745 if (EC && R && ED->isScoped())
12748 ? diag::warn_cxx17_compat_using_decl_scoped_enumerator
12749 : diag::ext_using_decl_scoped_enumerator)
12753 NamedContext = ED->getDeclContext();
12757 if (!CurContext->isRecord()) {
12773 ? diag::warn_cxx17_compat_using_decl_class_member_enumerator
12774 : diag::err_using_decl_can_not_refer_to_class_member)
12777 if (Cxx20Enumerator)
12780 auto *RD = NamedContext
12783 if (RD && !RequireCompleteDeclContext(
const_cast<CXXScopeSpec &
>(SS), RD)) {
12792 Diag(SS.
getBeginLoc(), diag::note_using_decl_class_member_workaround)
12800 Diag(InsertLoc, diag::note_using_decl_class_member_workaround)
12816 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
12831 Diag(UsingLoc, diag::note_using_decl_class_member_workaround)
12832 << (getLangOpts().CPlusPlus11 ? 4 : 3)
12841 if (!NamedContext) {
12857 ? diag::warn_cxx17_compat_using_decl_non_member_enumerator
12858 : diag::err_using_decl_nested_name_specifier_is_not_class)
12861 if (Cxx20Enumerator)
12868 RequireCompleteDeclContext(
const_cast<CXXScopeSpec&
>(SS), NamedContext))
12878 cast<CXXRecordDecl>(NamedContext))) {
12880 if (Cxx20Enumerator) {
12881 Diag(NameLoc, diag::warn_cxx17_compat_using_decl_non_member_enumerator)
12886 if (CurContext == NamedContext) {
12888 diag::err_using_decl_nested_name_specifier_is_current_class)
12890 return !getLangOpts().CPlusPlus20;
12893 if (!cast<CXXRecordDecl>(NamedContext)->isInvalidDecl()) {
12895 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12920 Bases.insert(
Base);
12925 if (!cast<CXXRecordDecl>(CurContext)->forallBases(Collect))
12931 return !Bases.count(
Base);
12936 if (Bases.count(cast<CXXRecordDecl>(NamedContext)) ||
12937 !cast<CXXRecordDecl>(NamedContext)->forallBases(IsNotBase))
12941 diag::err_using_decl_nested_name_specifier_is_not_base_class)
12955 while (S->isTemplateParamScope())
12956 S = S->getParent();
12958 "got alias-declaration outside of declaration scope");
12960 if (
Type.isInvalid())
12966 GetTypeFromParser(
Type.get(), &TInfo);
12968 if (DiagnoseClassNameShadow(CurContext, NameInfo))
12971 if (DiagnoseUnexpandedParameterPack(Name.StartLocation, TInfo,
12972 UPPC_DeclarationType)) {
12979 TemplateParamLists.size()
12980 ? forRedeclarationInCurContext()
12981 : ForVisibleRedeclaration);
12986 Previous.getFoundDecl()->isTemplateParameter()) {
12987 DiagnoseTemplateParameterShadow(Name.StartLocation,
Previous.getFoundDecl());
12991 assert(Name.Kind == UnqualifiedIdKind::IK_Identifier &&
12992 "name in alias declaration must be an identifier");
12994 Name.StartLocation,
12995 Name.Identifier, TInfo);
13002 ProcessDeclAttributeList(S, NewTD, AttrList);
13003 AddPragmaAttributes(S, NewTD);
13005 CheckTypedefForVariablyModifiedType(S, NewTD);
13008 bool Redeclaration =
false;
13011 if (TemplateParamLists.size()) {
13015 if (TemplateParamLists.size() != 1) {
13016 Diag(UsingLoc, diag::err_alias_template_extra_headers)
13017 <<
SourceRange(TemplateParamLists[1]->getTemplateLoc(),
13018 TemplateParamLists[TemplateParamLists.size()-1]->getRAngleLoc());
13023 if (CheckTemplateDeclScope(S, TemplateParams))
13027 FilterLookupForScope(
Previous, CurContext, S,
false,
13030 Redeclaration =
true;
13034 Diag(UsingLoc, diag::err_redefinition_different_kind)
13035 << Name.Identifier;
13045 if (TemplateParameterListsAreEqual(TemplateParams,
13048 TPL_TemplateMatch))
13049 OldTemplateParams =
13071 if (CheckTemplateParameterList(TemplateParams, OldTemplateParams,
13072 TPC_TypeAliasTemplate))
13077 Name.Identifier, TemplateParams,
13085 else if (OldDecl) {
13087 CheckRedeclarationInModule(NewDecl, OldDecl);
13092 if (
auto *TD = dyn_cast_or_null<TagDecl>(DeclFromDeclSpec)) {
13093 setTagNameForLinkagePurposes(TD, NewTD);
13094 handleTagNumbering(TD, S);
13096 ActOnTypedefNameDecl(S, CurContext, NewTD,
Previous, Redeclaration);
13100 PushOnScopeChains(NewND, S);
13101 ActOnDocumentableDecl(NewND);
13112 LookupResult R(*
this, Ident, IdentLoc, LookupNamespaceName);
13113 LookupParsedName(R, S, &SS);
13120 Diag(IdentLoc, diag::err_expected_namespace_name) << SS.
getRange();
13128 LookupResult PrevR(*
this, Alias, AliasLoc, LookupOrdinaryName,
13129 ForVisibleRedeclaration);
13130 LookupName(PrevR, S);
13134 DiagnoseTemplateParameterShadow(AliasLoc, PrevR.
getFoundDecl());
13139 FilterLookupForScope(PrevR, CurContext, S,
false,
13151 }
else if (isVisible(PrevDecl)) {
13152 Diag(AliasLoc, diag::err_redefinition_different_namespace_alias)
13154 Diag(AD->getLocation(), diag::note_previous_namespace_alias)
13155 << AD->getNamespace();
13158 }
else if (isVisible(PrevDecl)) {
13160 ? diag::err_redefinition
13161 : diag::err_redefinition_different_kind;
13162 Diag(AliasLoc, DiagID) << Alias;
13169 DiagnoseUseOfDecl(ND, IdentLoc);
13183struct SpecialMemberExceptionSpecInfo
13184 : SpecialMemberVisitor<SpecialMemberExceptionSpecInfo> {
13192 : SpecialMemberVisitor(S, MD, CSM, ICI), Loc(Loc), ExceptSpec(S) {}
13197 void visitClassSubobject(
CXXRecordDecl *Class, Subobject Subobj,
13200 void visitSubobjectCall(Subobject Subobj,
13212 if (
auto *BaseCtor = SMOR.
getMethod()) {
13213 visitSubobjectCall(
Base, BaseCtor);
13217 visitClassSubobject(BaseClass,
Base, 0);
13221bool SpecialMemberExceptionSpecInfo::visitField(
FieldDecl *FD) {
13235 visitClassSubobject(cast<CXXRecordDecl>(RT->getDecl()), FD,
13241void SpecialMemberExceptionSpecInfo::visitClassSubobject(
CXXRecordDecl *Class,
13245 bool IsMutable =
Field &&
Field->isMutable();
13246 visitSubobjectCall(Subobj, lookupIn(Class, Quals, IsMutable));
13249void SpecialMemberExceptionSpecInfo::visitSubobjectCall(
13254 ExceptSpec.
CalledDecl(getSubobjectLoc(Subobj), MD);
13258 llvm::APSInt Result;
13260 ExplicitSpec.
getExpr(), Context.
BoolTy, Result, CCEK_ExplicitBool);
13263 ExplicitSpec.
setKind(Result.getBoolValue()
13264 ? ExplicitSpecKind::ResolvedTrue
13265 : ExplicitSpecKind::ResolvedFalse);
13268 ExplicitSpec.
setKind(ExplicitSpecKind::Unresolved);
13275 tryResolveExplicitSpecifier(ES);
13283 ComputingExceptionSpec CES(S, MD, Loc);
13290 SpecialMemberExceptionSpecInfo Info(S, MD, CSM, ICI, MD->
getLocation());
13292 return Info.ExceptSpec;
13299 diag::err_exception_spec_incomplete_type))
13300 return Info.ExceptSpec;
13317 Info.visit(Info.IsConstructor ? Info.VisitPotentiallyConstructedBases
13318 : Info.VisitAllBases);
13320 return Info.ExceptSpec;
13325struct DeclaringSpecialMember {
13329 bool WasAlreadyBeingDeclared;
13332 : S(S), D(RD, CSM), SavedContext(S, RD) {
13334 if (WasAlreadyBeingDeclared)
13341 Sema::CodeSynthesisContext Ctx;
13342 Ctx.Kind = Sema::CodeSynthesisContext::DeclaringSpecialMember;
13349 Ctx.PointOfInstantiation = RD->getLocation();
13351 Ctx.SpecialMember = CSM;
13352 S.pushCodeSynthesisContext(Ctx);
13355 ~DeclaringSpecialMember() {
13356 if (!WasAlreadyBeingDeclared) {
13363 bool isAlreadyBeingDeclared()
const {
13364 return WasAlreadyBeingDeclared;
13374 ForExternalRedeclaration);
13381 CheckFunctionDeclaration(S, FD, R,
false,
13385void Sema::setupImplicitSpecialMemberType(
CXXMethodDecl *SpecialMem,
13391 LangAS AS = getDefaultCXXMethodAddrSpace();
13392 if (AS != LangAS::Default) {
13402 if (inTemplateInstantiation() &&
13403 cast<CXXRecordDecl>(SpecialMem->
getParent())->isLambda()) {
13419 "Should not build implicit default constructor!");
13421 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDefaultConstructor);
13422 if (DSM.isAlreadyBeingDeclared())
13426 CXXDefaultConstructor,
13437 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
13439 getCurFPFeatures().isFPConstrained(),
13441 Constexpr ? ConstexprSpecKind::Constexpr
13442 : ConstexprSpecKind::Unspecified);
13446 setupImplicitSpecialMemberType(DefaultCon, Context.
VoidTy, None);
13448 if (getLangOpts().
CUDA)
13449 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDefaultConstructor,
13459 ++getASTContext().NumImplicitDefaultConstructorsDeclared;
13461 Scope *S = getScopeForContext(ClassDecl);
13462 CheckImplicitSpecialMemberDeclaration(S, DefaultCon);
13464 if (ShouldDeleteSpecialMember(DefaultCon, CXXDefaultConstructor))
13465 SetDeclDeleted(DefaultCon, ClassLoc);
13468 PushOnScopeChains(DefaultCon, S,
false);
13469 ClassDecl->
addDecl(DefaultCon);
13476 assert((Constructor->isDefaulted() && Constructor->isDefaultConstructor() &&
13477 !Constructor->doesThisDeclarationHaveABody() &&
13478 !Constructor->isDeleted()) &&
13479 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
13480 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13484 assert(ClassDecl &&
"DefineImplicitDefaultConstructor - invalid constructor");
13490 ResolveExceptionSpec(CurrentLocation,
13492 MarkVTableUsed(CurrentLocation, ClassDecl);
13495 Scope.addContextNote(CurrentLocation);
13497 if (SetCtorInitializers(Constructor,
false)) {
13498 Constructor->setInvalidDecl();
13503 ? Constructor->getEndLoc()
13504 : Constructor->getLocation();
13505 Constructor->setBody(
new (Context)
CompoundStmt(Loc));
13506 Constructor->markUsed(Context);
13509 L->CompletedImplicitDefinition(Constructor);
13512 DiagnoseUninitializedFields(*
this, Constructor);
13517 CheckDelayedMemberExceptionSpecs();
13538 ->getInheritedConstructor()
13556 false, BaseCtor, &ICI);
13559 Context, Derived, UsingLoc, NameInfo, TInfo->
getType(), TInfo,
13573 EPI.ExceptionSpec.SourceDecl = DerivedCtor;
13583 Context, DerivedCtor, UsingLoc, UsingLoc,
nullptr,
13590 ParamDecls.push_back(PD);
13595 assert(!BaseCtor->
isDeleted() &&
"should not use deleted constructor");
13598 Derived->
addDecl(DerivedCtor);
13600 if (ShouldDeleteSpecialMember(DerivedCtor, CXXDefaultConstructor, &ICI))
13601 SetDeclDeleted(DerivedCtor, UsingLoc);
13603 return DerivedCtor;
13609 ShouldDeleteSpecialMember(Ctor, CXXDefaultConstructor, &ICI,
13616 assert(Constructor->getInheritedConstructor() &&
13617 !Constructor->doesThisDeclarationHaveABody() &&
13618 !Constructor->isDeleted());
13619 if (Constructor->willHaveBody() || Constructor->isInvalidDecl())
13628 ResolveExceptionSpec(CurrentLocation,
13630 MarkVTableUsed(CurrentLocation, ClassDecl);
13633 Scope.addContextNote(CurrentLocation);
13636 Constructor->getInheritedConstructor().getShadowDecl();
13638 Constructor->getInheritedConstructor().getConstructor();
13652 for (
bool VBase : {
false,
true}) {
13654 if (B.isVirtual() != VBase)
13657 auto *BaseRD = B.getType()->getAsCXXRecordDecl();
13662 if (!BaseCtor.first)
13665 MarkFunctionReferenced(CurrentLocation, BaseCtor.first);
13667 InitLoc, B.getType(), BaseCtor.first, VBase, BaseCtor.second);
13671 Context, TInfo, VBase, InitLoc, Init.get(), InitLoc,
13679 if (SetCtorInitializers(Constructor,
false, Inits)) {
13680 Constructor->setInvalidDecl();
13684 Constructor->setBody(
new (Context)
CompoundStmt(InitLoc));
13685 Constructor->markUsed(Context);
13688 L->CompletedImplicitDefinition(Constructor);
13691 DiagnoseUninitializedFields(*
this, Constructor);
13701 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXDestructor);
13702 if (DSM.isAlreadyBeingDeclared())
13717 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
13718 getCurFPFeatures().isFPConstrained(),
13721 Constexpr ? ConstexprSpecKind::Constexpr
13722 : ConstexprSpecKind::Unspecified);
13724 Destructor->setDefaulted();
13726 setupImplicitSpecialMemberType(Destructor, Context.
VoidTy, None);
13728 if (getLangOpts().
CUDA)
13729 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXDestructor,
13737 Destructor->setTrivialForCall(ClassDecl->
hasAttr<TrivialABIAttr>() ||
13741 ++getASTContext().NumImplicitDestructorsDeclared;
13743 Scope *S = getScopeForContext(ClassDecl);
13744 CheckImplicitSpecialMemberDeclaration(S, Destructor);
13750 ShouldDeleteSpecialMember(Destructor, CXXDestructor))
13751 SetDeclDeleted(Destructor, ClassLoc);
13755 PushOnScopeChains(Destructor, S,
false);
13756 ClassDecl->
addDecl(Destructor);
13763 assert((Destructor->isDefaulted() &&
13764 !Destructor->doesThisDeclarationHaveABody() &&
13765 !Destructor->isDeleted()) &&
13766 "DefineImplicitDestructor - call it for implicit default dtor");
13767 if (Destructor->willHaveBody() || Destructor->isInvalidDecl())
13771 assert(ClassDecl &&
"DefineImplicitDestructor - invalid destructor");
13777 ResolveExceptionSpec(CurrentLocation,
13779 MarkVTableUsed(CurrentLocation, ClassDecl);
13782 Scope.addContextNote(CurrentLocation);
13784 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
13785 Destructor->getParent());
13787 if (CheckDestructor(Destructor)) {
13788 Destructor->setInvalidDecl();
13793 ? Destructor->getEndLoc()
13794 : Destructor->getLocation();
13796 Destructor->markUsed(Context);
13799 L->CompletedImplicitDefinition(Destructor);
13805 if (Destructor->isInvalidDecl())
13810 "implicit complete dtors unneeded outside MS ABI");
13812 "complete dtor only exists for classes with vbases");
13817 Scope.addContextNote(CurrentLocation);
13819 MarkVirtualBaseDestructorsReferenced(Destructor->getLocation(), ClassDecl);
13826 if (
CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(CurContext)) {
13827 if (Record->isInvalidDecl()) {
13828 DelayedOverridingExceptionSpecChecks.clear();
13829 DelayedEquivalentExceptionSpecChecks.clear();
13837 referenceDLLExportedClassMethods();
13839 if (!DelayedDllExportMemberFunctions.empty()) {
13841 std::swap(DelayedDllExportMemberFunctions, WorkList);
13848 if (M->getParent()->getTemplateSpecializationKind() !=
13850 ActOnFinishInlineFunctionDef(M);
13856 if (!DelayedDllExportClasses.empty()) {
13860 std::swap(DelayedDllExportClasses, WorkList);
13868 "adjusting dtor exception specs was introduced in c++11");
13870 if (Destructor->isDependentContext())
13878 if (DtorType->hasExceptionSpec())
13901 ExprBuilder(
const ExprBuilder&) =
delete;
13902 ExprBuilder &operator=(
const ExprBuilder&) =
delete;
13905 static Expr *assertNotNull(
Expr *E) {
13906 assert(E &&
"Expression construction must not fail.");
13912 virtual ~ExprBuilder() {}
13917class RefBuilder:
public ExprBuilder {
13927 : Var(Var), VarType(VarType) {}
13930class ThisBuilder:
public ExprBuilder {
13937class CastBuilder:
public ExprBuilder {
13938 const ExprBuilder &Builder;
13946 CK_UncheckedDerivedToBase, Kind,
13952 : Builder(Builder),
Type(
Type), Kind(Kind), Path(Path) {}
13955class DerefBuilder:
public ExprBuilder {
13956 const ExprBuilder &Builder;
13960 return assertNotNull(
13964 DerefBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
13967class MemberBuilder:
public ExprBuilder {
13968 const ExprBuilder &Builder;
13978 nullptr, MemberLookup,
nullptr,
nullptr).get());
13981 MemberBuilder(
const ExprBuilder &Builder,
QualType Type,
bool IsArrow,
13983 : Builder(Builder),
Type(
Type), IsArrow(IsArrow),
13984 MemberLookup(MemberLookup) {}
13987class MoveCastBuilder:
public ExprBuilder {
13988 const ExprBuilder &Builder;
13992 return assertNotNull(
CastForMoving(S, Builder.build(S, Loc)));
13995 MoveCastBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
13998class LvalueConvBuilder:
public ExprBuilder {
13999 const ExprBuilder &Builder;
14003 return assertNotNull(
14007 LvalueConvBuilder(
const ExprBuilder &Builder) : Builder(Builder) {}
14010class SubscriptBuilder:
public ExprBuilder {
14011 const ExprBuilder &
Base;
14012 const ExprBuilder &Index;
14017 Base.build(S, Loc), Loc, Index.build(S, Loc), Loc).
get());
14020 SubscriptBuilder(
const ExprBuilder &
Base,
const ExprBuilder &Index)
14032 const ExprBuilder &ToB,
const ExprBuilder &FromB) {
14041 Expr *From = FromB.build(S, Loc);
14045 Expr *To = ToB.build(S, Loc);
14050 const Type *E = T->getBaseElementTypeUnsafe();
14051 bool NeedsCollectableMemCpy =
14056 StringRef MemCpyName = NeedsCollectableMemCpy ?
14057 "__builtin_objc_memmove_collectable" :
14058 "__builtin_memcpy";
14071 assert(MemCpyRef.
isUsable() &&
"Builtin reference cannot fail");
14073 Expr *CallArgs[] = {
14077 Loc, CallArgs, Loc);
14079 assert(!Call.isInvalid() &&
"Call to __builtin_memcpy cannot fail!");
14080 return Call.getAs<
Stmt>();
14112 const ExprBuilder &To,
const ExprBuilder &From,
14113 bool CopyingBaseSubobject,
bool Copying,
14114 unsigned Depth = 0) {
14145 if (Method->isCopyAssignmentOperator() ||
14146 (!Copying && Method->isMoveAssignmentOperator()))
14165 if (CopyingBaseSubobject) {
14196 Expr *FromInst = From.build(S, Loc);
14199 Loc, FromInst, Loc);
14200 if (Call.isInvalid())
14219 Loc, BO_Assign, To.build(S, Loc), From.build(S, Loc));
14220 if (Assignment.isInvalid())
14239 llvm::raw_svector_ostream OS(Str);
14240 OS <<
"__i" << Depth;
14244 IterationVarName, SizeType,
14253 RefBuilder IterationVarRef(IterationVar, SizeType);
14254 LvalueConvBuilder IterationVarRefRVal(IterationVarRef);
14260 SubscriptBuilder FromIndexCopy(From, IterationVarRefRVal);
14261 MoveCastBuilder FromIndexMove(FromIndexCopy);
14262 const ExprBuilder *FromIndex;
14264 FromIndex = &FromIndexCopy;
14266 FromIndex = &FromIndexMove;
14268 SubscriptBuilder ToIndex(To, IterationVarRefRVal);
14273 ToIndex, *FromIndex, CopyingBaseSubobject,
14274 Copying, Depth + 1);
14276 if (Copy.isInvalid() || !Copy.get())
14283 S.
Context, IterationVarRefRVal.build(S, Loc),
14297 Loc, Loc, InitStmt,
14298 S.
ActOnCondition(
nullptr, Loc, Comparison, Sema::ConditionKind::Boolean),
14304 const ExprBuilder &To,
const ExprBuilder &From,
14305 bool CopyingBaseSubobject,
bool Copying) {
14307 if (T->isArrayType() && !T.isConstQualified() && !T.isVolatileQualified() &&
14308 T.isTriviallyCopyableType(S.
Context))
14312 CopyingBaseSubobject,
14317 if (!Result.isInvalid() && !Result.get())
14330 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyAssignment);
14331 if (DSM.isAlreadyBeingDeclared())
14335 LangAS AS = getDefaultCXXMethodAddrSpace();
14336 if (AS != LangAS::Default)
14341 ArgType = ArgType.withConst();
14355 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
14357 getCurFPFeatures().isFPConstrained(),
14359 Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified,
14365 setupImplicitSpecialMemberType(CopyAssignment, RetType, ArgType);
14367 if (getLangOpts().
CUDA)
14368 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyAssignment,
14375 ClassLoc, ClassLoc,
14383 ? SpecialMemberIsTrivial(CopyAssignment, CXXCopyAssignment)
14387 ++getASTContext().NumImplicitCopyAssignmentOperatorsDeclared;
14389 Scope *S = getScopeForContext(ClassDecl);
14390 CheckImplicitSpecialMemberDeclaration(S, CopyAssignment);
14392 if (ShouldDeleteSpecialMember(CopyAssignment, CXXCopyAssignment)) {
14394 SetDeclDeleted(CopyAssignment, ClassLoc);
14398 PushOnScopeChains(CopyAssignment, S,
false);
14399 ClassDecl->
addDecl(CopyAssignment);
14401 return CopyAssignment;
14417 }
else if (!isa<CXXConstructorDecl>(CopyOp) &&
14421 for (
auto *I : RD->
ctors()) {
14422 if (I->isCopyConstructor()) {
14423 UserDeclaredOperation = I;
14427 assert(UserDeclaredOperation);
14428 }
else if (isa<CXXConstructorDecl>(CopyOp) &&
14432 for (
auto *I : RD->
methods()) {
14433 if (I->isCopyAssignmentOperator()) {
14434 UserDeclaredOperation = I;
14438 assert(UserDeclaredOperation);
14441 if (UserDeclaredOperation) {
14442 bool UDOIsUserProvided = UserDeclaredOperation->
isUserProvided();
14446 (UDOIsUserProvided && UDOIsDestructor)
14447 ? diag::warn_deprecated_copy_with_user_provided_dtor
14448 : (UDOIsUserProvided && !UDOIsDestructor)
14449 ? diag::warn_deprecated_copy_with_user_provided_copy
14450 : (!UDOIsUserProvided && UDOIsDestructor)
14451 ? diag::warn_deprecated_copy_with_dtor
14452 : diag::warn_deprecated_copy;
14454 << RD << IsCopyAssignment;
14465 "DefineImplicitCopyAssignment called for wrong function");
14479 ResolveExceptionSpec(CurrentLocation,
14483 Scope.addContextNote(CurrentLocation);
14519 RefBuilder OtherRef(Other, OtherRefType);
14526 for (
auto &
Base : ClassDecl->
bases()) {
14529 QualType BaseType =
Base.getType().getUnqualifiedType();
14530 if (!BaseType->isRecordType()) {
14536 BasePath.push_back(&
Base);
14540 CastBuilder From(OtherRef, Context.
getQualifiedType(BaseType, OtherQuals),
14544 DerefBuilder DerefThis(This);
14545 CastBuilder To(DerefThis,
14561 Statements.push_back(Copy.
getAs<
Expr>());
14565 for (
auto *Field : ClassDecl->
fields()) {
14568 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
14571 if (Field->isInvalidDecl()) {
14577 if (Field->getType()->isReferenceType()) {
14578 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14579 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
14580 Diag(Field->getLocation(), diag::note_declared_at);
14587 if (!BaseType->getAs<
RecordType>() && BaseType.isConstQualified()) {
14588 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14589 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
14590 Diag(Field->getLocation(), diag::note_declared_at);
14596 if (Field->isZeroLengthBitField(Context))
14599 QualType FieldType = Field->getType().getNonReferenceType();
14602 "Incomplete array type is not valid");
14608 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
14613 MemberBuilder From(OtherRef, OtherRefType,
false, MemberLookup);
14615 MemberBuilder To(This, getCurrentThisType(),
true, MemberLookup);
14628 Statements.push_back(Copy.
getAs<
Stmt>());
14633 ExprResult ThisObj = CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
14639 Statements.push_back(Return.
getAs<
Stmt>());
14650 Body = ActOnCompoundStmt(Loc, Loc, Statements,
14652 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
14655 CopyAssignOperator->
markUsed(Context);
14658 L->CompletedImplicitDefinition(CopyAssignOperator);
14665 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveAssignment);
14666 if (DSM.isAlreadyBeingDeclared())
14673 LangAS AS = getDefaultCXXMethodAddrSpace();
14674 if (AS != LangAS::Default)
14689 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
14691 getCurFPFeatures().isFPConstrained(),
14693 Constexpr ? ConstexprSpecKind::Constexpr : ConstexprSpecKind::Unspecified,
14699 setupImplicitSpecialMemberType(MoveAssignment, RetType, ArgType);
14701 if (getLangOpts().
CUDA)
14702 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveAssignment,
14709 ClassLoc, ClassLoc,
14717 ? SpecialMemberIsTrivial(MoveAssignment, CXXMoveAssignment)
14721 ++getASTContext().NumImplicitMoveAssignmentOperatorsDeclared;
14723 Scope *S = getScopeForContext(ClassDecl);
14724 CheckImplicitSpecialMemberDeclaration(S, MoveAssignment);
14726 if (ShouldDeleteSpecialMember(MoveAssignment, CXXMoveAssignment)) {
14728 SetDeclDeleted(MoveAssignment, ClassLoc);
14732 PushOnScopeChains(MoveAssignment, S,
false);
14733 ClassDecl->
addDecl(MoveAssignment);
14735 return MoveAssignment;
14743 assert(!Class->isDependentContext() &&
"should not define dependent move");
14749 if (Class->getNumVBases() == 0 || Class->hasTrivialMoveAssignment() ||
14750 Class->getNumBases() < 2)
14754 typedef llvm::DenseMap<CXXRecordDecl*, CXXBaseSpecifier*> VBaseMap;
14757 for (
auto &BI : Class->bases()) {
14758 Worklist.push_back(&BI);
14759 while (!Worklist.empty()) {
14765 if (!
Base->hasNonTrivialMoveAssignment())
14790 VBases.insert(std::make_pair(
Base->getCanonicalDecl(), &BI))
14792 if (Existing && Existing != &BI) {
14793 S.
Diag(CurrentLocation, diag::warn_vbase_moved_multiple_times)
14796 << (
Base->getCanonicalDecl() ==
14799 S.
Diag(BI.getBeginLoc(), diag::note_vbase_moved_here)
14800 << (
Base->getCanonicalDecl() ==
14801 BI.getType()->getAsCXXRecordDecl()->getCanonicalDecl())
14805 Existing =
nullptr;
14815 llvm::append_range(Worklist, llvm::make_pointer_range(
Base->bases()));
14828 "DefineImplicitMoveAssignment called for wrong function");
14854 ResolveExceptionSpec(CurrentLocation,
14858 Scope.addContextNote(CurrentLocation);
14874 RefBuilder OtherRef(Other, OtherRefType);
14876 MoveCastBuilder MoveOther(OtherRef);
14883 for (
auto &
Base : ClassDecl->
bases()) {
14894 QualType BaseType =
Base.getType().getUnqualifiedType();
14895 if (!BaseType->isRecordType()) {
14901 BasePath.push_back(&
Base);
14905 CastBuilder From(OtherRef, BaseType,
VK_XValue, BasePath);
14908 DerefBuilder DerefThis(This);
14911 CastBuilder To(DerefThis,
14921 if (Move.isInvalid()) {
14927 Statements.push_back(Move.getAs<
Expr>());
14931 for (
auto *Field : ClassDecl->
fields()) {
14934 if (Field->isUnnamedBitfield() || Field->getParent()->isUnion())
14937 if (Field->isInvalidDecl()) {
14943 if (Field->getType()->isReferenceType()) {
14944 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14945 << Context.
getTagDeclType(ClassDecl) << 0 << Field->getDeclName();
14946 Diag(Field->getLocation(), diag::note_declared_at);
14953 if (!BaseType->getAs<
RecordType>() && BaseType.isConstQualified()) {
14954 Diag(ClassDecl->
getLocation(), diag::err_uninitialized_member_for_assign)
14955 << Context.
getTagDeclType(ClassDecl) << 1 << Field->getDeclName();
14956 Diag(Field->getLocation(), diag::note_declared_at);
14962 if (Field->isZeroLengthBitField(Context))
14965 QualType FieldType = Field->getType().getNonReferenceType();
14968 "Incomplete array type is not valid");
14973 LookupResult MemberLookup(*
this, Field->getDeclName(), Loc,
14977 MemberBuilder From(MoveOther, OtherRefType,
14978 false, MemberLookup);
14979 MemberBuilder To(This, getCurrentThisType(),
14980 true, MemberLookup);
14982 assert(!From.build(*
this, Loc)->isLValue() &&
14983 "Member reference with rvalue base must be rvalue except for reference "
14984 "members, which aren't allowed for move assignment.");
14991 if (Move.isInvalid()) {
14997 Statements.push_back(Move.getAs<
Stmt>());
15003 CreateBuiltinUnaryOp(Loc, UO_Deref, This.build(*
this, Loc));
15009 Statements.push_back(Return.
getAs<
Stmt>());
15020 Body = ActOnCompoundStmt(Loc, Loc, Statements,
15022 assert(!Body.
isInvalid() &&
"Compound statement creation cannot fail");
15025 MoveAssignOperator->
markUsed(Context);
15028 L->CompletedImplicitDefinition(MoveAssignOperator);
15039 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXCopyConstructor);
15040 if (DSM.isAlreadyBeingDeclared())
15047 ArgType = ArgType.withConst();
15049 LangAS AS = getDefaultCXXMethodAddrSpace();
15050 if (AS != LangAS::Default)
15056 CXXCopyConstructor,
15068 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
15072 Constexpr ? ConstexprSpecKind::Constexpr
15073 : ConstexprSpecKind::Unspecified);
15077 setupImplicitSpecialMemberType(CopyConstructor, Context.
VoidTy, ArgType);
15079 if (getLangOpts().
CUDA)
15080 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXCopyConstructor,
15089 if (inTemplateInstantiation() && ClassDecl->
isLambda())
15101 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor)
15105 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15107 ? SpecialMemberIsTrivial(CopyConstructor, CXXCopyConstructor,
15108 TAH_ConsiderTrivialABI)
15112 ++getASTContext().NumImplicitCopyConstructorsDeclared;
15114 Scope *S = getScopeForContext(ClassDecl);
15115 CheckImplicitSpecialMemberDeclaration(S, CopyConstructor);
15117 if (ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) {
15119 SetDeclDeleted(CopyConstructor, ClassLoc);
15123 PushOnScopeChains(CopyConstructor, S,
false);
15124 ClassDecl->
addDecl(CopyConstructor);
15126 return CopyConstructor;
15135 "DefineImplicitCopyConstructor - call it for implicit copy ctor");
15140 assert(ClassDecl &&
"DefineImplicitCopyConstructor - invalid constructor");
15146 ResolveExceptionSpec(CurrentLocation,
15148 MarkVTableUsed(CurrentLocation, ClassDecl);
15151 Scope.addContextNote(CurrentLocation);
15160 if (SetCtorInitializers(CopyConstructor,
false)) {
15168 ActOnCompoundStmt(Loc, Loc, None,
false).getAs<Stmt>());
15169 CopyConstructor->
markUsed(Context);
15173 L->CompletedImplicitDefinition(CopyConstructor);
15181 DeclaringSpecialMember DSM(*
this, ClassDecl, CXXMoveConstructor);
15182 if (DSM.isAlreadyBeingDeclared())
15188 LangAS AS = getDefaultCXXMethodAddrSpace();
15189 if (AS != LangAS::Default)
15194 CXXMoveConstructor,
15207 Context, ClassDecl, ClassLoc, NameInfo,
QualType(),
nullptr,
15211 Constexpr ? ConstexprSpecKind::Constexpr
15212 : ConstexprSpecKind::Unspecified);
15216 setupImplicitSpecialMemberType(MoveConstructor, Context.
VoidTy, ArgType);
15218 if (getLangOpts().
CUDA)
15219 inferCUDATargetForImplicitSpecialMember(ClassDecl, CXXMoveConstructor,
15226 ClassLoc, ClassLoc,
15234 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor)
15238 ClassDecl->
hasAttr<TrivialABIAttr>() ||
15240 ? SpecialMemberIsTrivial(MoveConstructor, CXXMoveConstructor,
15241 TAH_ConsiderTrivialABI)
15245 ++getASTContext().NumImplicitMoveConstructorsDeclared;
15247 Scope *S = getScopeForContext(ClassDecl);
15248 CheckImplicitSpecialMemberDeclaration(S, MoveConstructor);
15250 if (ShouldDeleteSpecialMember(MoveConstructor, CXXMoveConstructor)) {
15252 SetDeclDeleted(MoveConstructor, ClassLoc);
15256 PushOnScopeChains(MoveConstructor, S,
false);
15257 ClassDecl->
addDecl(MoveConstructor);
15259 return MoveConstructor;
15268 "DefineImplicitMoveConstructor - call it for implicit move ctor");
15273 assert(ClassDecl &&
"DefineImplicitMoveConstructor - invalid constructor");
15279 ResolveExceptionSpec(CurrentLocation,
15281 MarkVTableUsed(CurrentLocation, ClassDecl);
15284 Scope.addContextNote(CurrentLocation);
15286 if (SetCtorInitializers(MoveConstructor,
false)) {
15293 MoveConstructor->
setBody(ActOnCompoundStmt(
15294 Loc, Loc, None,
false).getAs<Stmt>());
15295 MoveConstructor->
markUsed(Context);
15299 L->CompletedImplicitDefinition(MoveConstructor);
15322 CallOp = InstantiateFunctionDeclaration(
15327 Invoker = InstantiateFunctionDeclaration(
15341 MarkFunctionReferenced(CurrentLocation, CallOp);
15352 Expr *FunctionRef = BuildDeclRefExpr(Invoker, Invoker->
getType(),
15354 assert(FunctionRef &&
"Can't refer to __invoke function?");
15355 Stmt *Return = BuildReturnStmt(Conv->
getLocation(), FunctionRef).get();
15362 L->CompletedImplicitDefinition(Conv);
15363 L->CompletedImplicitDefinition(Invoker);
15378 Expr *This = ActOnCXXThis(CurrentLocation).get();
15379 Expr *DerefThis =CreateBuiltinUnaryOp(CurrentLocation, UO_Deref, This).get();
15381 ExprResult BuildBlock = BuildBlockForLambdaConversion(CurrentLocation,
15389 if (!BuildBlock.
isInvalid() && !getLangOpts().ObjCAutoRefCount)
15391 Context, BuildBlock.
get()->
getType(), CK_CopyAndAutoreleaseBlockObject,
15395 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
15404 Diag(CurrentLocation, diag::note_lambda_to_block_conv);
15410 Stmt *ReturnS = Return.
get();
15417 L->CompletedImplicitDefinition(Conv);
15424 switch (Args.size()) {
15429 if (!Args[1]->isDefaultArgument())
15434 return !Args[0]->isDefaultArgument();
15445 bool HadMultipleCandidates,
15446 bool IsListInitialization,
15447 bool IsStdInitListInitialization,
15448 bool RequiresZeroInit,
15449 unsigned ConstructKind,
15451 bool Elidable =
false;
15470 Expr *SubExpr = ExprArgs[0];
15479 return BuildCXXConstructExpr(ConstructLoc, DeclInitType,
15480 FoundDecl, Constructor,
15481 Elidable, ExprArgs, HadMultipleCandidates,
15482 IsListInitialization,
15483 IsStdInitListInitialization, RequiresZeroInit,
15484 ConstructKind, ParenRange);
15493 bool HadMultipleCandidates,
15494 bool IsListInitialization,
15495 bool IsStdInitListInitialization,
15496 bool RequiresZeroInit,
15497 unsigned ConstructKind,
15499 if (
auto *Shadow = dyn_cast<ConstructorUsingShadowDecl>(FoundDecl)) {
15500 Constructor = findInheritingConstructor(ConstructLoc, Constructor, Shadow);
15501 if (DiagnoseUseOfDecl(Constructor, ConstructLoc))
15505 return BuildCXXConstructExpr(
15506 ConstructLoc, DeclInitType, Constructor, Elidable, ExprArgs,
15507 HadMultipleCandidates, IsListInitialization, IsStdInitListInitialization,
15508 RequiresZeroInit, ConstructKind, ParenRange);
15518 bool HadMultipleCandidates,
15519 bool IsListInitialization,
15520 bool IsStdInitListInitialization,
15521 bool RequiresZeroInit,
15522 unsigned ConstructKind,
15525 Constructor->getParent(),
15527 "given constructor for wrong type");
15528 MarkFunctionReferenced(ConstructLoc, Constructor);
15529 if (getLangOpts().
CUDA && !CheckCUDACall(ConstructLoc, Constructor))
15531 if (getLangOpts().SYCLIsDevice &&
15532 !checkSYCLDeviceFunction(ConstructLoc, Constructor))
15535 return CheckForImmediateInvocation(
15537 Context, DeclInitType, ConstructLoc, Constructor, Elidable, ExprArgs,
15538 HadMultipleCandidates, IsListInitialization,
15539 IsStdInitListInitialization, RequiresZeroInit,
15546 assert(Field->hasInClassInitializer());
15549 if (Field->getInClassInitializer())
15553 if (Field->isInvalidDecl())
15563 ClassPattern->
lookup(Field->getDeclName());
15566 for (
auto L : Lookup) {
15567 if (isa<FieldDecl>(L)) {
15572 assert(Pattern &&
"We must have set the Pattern!");
15575 InstantiateInClassInitializer(Loc, Field, Pattern,
15576 getTemplateInstantiationArgs(Field))) {
15578 Field->setInvalidDecl();
15599 Diag(Loc, diag::err_default_member_initializer_not_yet_parsed)
15600 << OutermostClass << Field;
15601 Diag(Field->getEndLoc(),
15602 diag::note_default_member_initializer_not_yet_parsed);
15604 if (!isSFINAEContext())
15605 Field->setInvalidDecl();
15630 MarkFunctionReferenced(VD->
getLocation(), Destructor);
15631 CheckDestructorAccess(VD->
getLocation(), Destructor,
15632 PDiag(diag::err_access_dtor_var)
15634 DiagnoseUseOfDecl(Destructor, VD->
getLocation());
15637 if (Destructor->isTrivial())
return;
15641 if (Destructor->isConstexpr()) {
15642 bool HasConstantInit =
false;
15649 diag::err_constexpr_var_requires_const_destruction) << VD;
15650 for (
unsigned I = 0,
N = Notes.size(); I !=
N; ++I)
15651 Diag(Notes[I].first, Notes[I].second);
15675 bool AllowExplicit,
15676 bool IsListInitialization) {
15678 unsigned NumArgs = ArgsPtr.size();
15679 Expr **Args = ArgsPtr.data();
15685 if (NumArgs < NumParams)
15686 ConvertedArgs.reserve(NumParams);
15688 ConvertedArgs.reserve(NumArgs);
15691 Proto->isVariadic() ? VariadicConstructor : VariadicDoesNotApply;
15693 bool Invalid = GatherArgumentsForCall(Loc, Constructor,
15695 llvm::makeArrayRef(Args, NumArgs),
15697 CallType, AllowExplicit,
15698 IsListInitialization);
15699 ConvertedArgs.append(AllArgs.begin(), AllArgs.end());
15701 DiagnoseSentinelCalls(Constructor, Loc, AllArgs);
15703 CheckConstructorCall(Constructor, DeclInitType,
15704 llvm::makeArrayRef(AllArgs.data(), AllArgs.size()),
15714 if (isa<NamespaceDecl>(DC)) {
15716 diag::err_operator_new_delete_declared_in_namespace)
15720 if (isa<TranslationUnitDecl>(DC) &&
15723 diag::err_operator_new_delete_declared_static)
15733 Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
15736 PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
15743 unsigned DependentParamTypeDiag,
15744 unsigned InvalidParamTypeDiag) {
15762 return SemaRef.
Diag(
15765 ? diag::err_operator_new_delete_dependent_result_type
15766 : diag::err_operator_new_delete_invalid_result_type)
15773 diag::err_operator_new_delete_template_too_few_parameters)
15779 diag::err_operator_new_delete_too_few_parameters)
15786 if (
const auto *PtrTy =
15791 ExpectedFirstParamType =
15797 ExpectedFirstParamType) {
15802 ? DependentParamTypeDiag
15803 : InvalidParamTypeDiag)
15804 << FnDecl->
getDeclName() << ExpectedFirstParamType;
15827 diag::err_operator_new_dependent_param_type,
15828 diag::err_operator_new_param_type))
15835 diag::err_operator_new_default_arg)
15850 auto *MD = dyn_cast<CXXMethodDecl>(FnDecl);
15865 SemaRef, FnDecl, SemaRef.
Context.
VoidTy, ExpectedFirstParamType,
15866 diag::err_operator_delete_dependent_param_type,
15867 diag::err_operator_delete_param_type))
15876 diag::err_destroying_operator_delete_not_usual);
15888 "Expected an overloaded operator declaration");
15898 if (Op == OO_Delete || Op == OO_Array_Delete)
15901 if (Op == OO_New || Op == OO_Array_New)
15909 if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(FnDecl)) {
15910 if (MethodDecl->isStatic())
15912 diag::err_operator_overload_static) << FnDecl->
getDeclName();
15914 bool ClassOrEnumParam =
false;
15916 QualType ParamType = Param->getType().getNonReferenceType();
15919 ClassOrEnumParam =
true;
15924 if (!ClassOrEnumParam)
15926 diag::err_operator_overload_needs_class_or_enum)
15936 if (Op != OO_Call) {
15939 if (Param->hasDefaultArg()) {
15940 FirstDefaultedParam = Param;
15944 if (FirstDefaultedParam) {
15945 if (Op == OO_Subscript) {
15947 ? diag::ext_subscript_overload
15948 : diag::error_subscript_overload)
15953 diag::err_operator_overload_default_arg)
15961 {
false,
false,
false }
15962#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
15963 , { Unary, Binary, MemberOnly }
15964#include "clang/Basic/OperatorKinds.def"
15967 bool CanBeUnaryOperator = OperatorUses[Op][0];
15968 bool CanBeBinaryOperator = OperatorUses[Op][1];
15969 bool MustBeMemberOperator = OperatorUses[Op][2];
15977 if (Op != OO_Call && Op != OO_Subscript &&
15978 ((NumParams == 1 && !CanBeUnaryOperator) ||
15979 (NumParams == 2 && !CanBeBinaryOperator) || (NumParams < 1) ||
15980 (NumParams > 2))) {
15982 unsigned ErrorKind;
15983 if (CanBeUnaryOperator && CanBeBinaryOperator) {
15985 }
else if (CanBeUnaryOperator) {
15988 assert(CanBeBinaryOperator &&
15989 "All non-call overloaded operators are unary or binary!");
15992 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_must_be)
15993 << FnDecl->
getDeclName() << NumParams << ErrorKind;
15996 if (Op == OO_Subscript && NumParams != 2) {
15998 ? diag::ext_subscript_overload
15999 : diag::error_subscript_overload)
16000 << FnDecl->
getDeclName() << (NumParams == 1 ? 0 : 2);
16005 if (Op != OO_Call &&
16007 return Diag(FnDecl->
getLocation(), diag::err_operator_overload_variadic)
16012 if (MustBeMemberOperator && !isa<CXXMethodDecl>(FnDecl)) {
16014 diag::err_operator_overload_must_be_member)
16028 if ((Op == OO_PlusPlus || Op == OO_MinusMinus) && NumParams == 2) {
16035 diag::err_operator_overload_post_incdec_must_be_int)
16036 << LastParam->
getType() << (Op == OO_MinusMinus);
16048 if (TemplateParams->
size() == 1) {
16050 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(0));
16064 if (SemaRef.
getLangOpts().CPlusPlus20 && PmDecl &&
16069 }
else if (TemplateParams->
size() == 2) {
16071 dyn_cast<TemplateTypeParmDecl>(TemplateParams->
getParam(0));
16073 dyn_cast<NonTypeTemplateParmDecl>(TemplateParams->
getParam(1));
16085 diag::ext_string_literal_operator_template);
16092 diag::err_literal_operator_template)
16101 if (isa<CXXMethodDecl>(FnDecl)) {
16102 Diag(FnDecl->
getLocation(), diag::err_literal_operator_outside_namespace)
16111 Diag(LSD->getExternLoc(), diag::note_extern_c_begins_here);
16130 diag::err_literal_operator_template_with_params);
16140 QualType ParamType = Param->getType().getUnqualifiedType();
16158 Diag(Param->getSourceRange().getBegin(),
16159 diag::err_literal_operator_param)
16160 << ParamType <<
"'const char *'" << Param->getSourceRange();
16165 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
16166 << ParamType << Context.
LongDoubleTy << Param->getSourceRange();
16170 Diag(Param->getSourceRange().getBegin(), diag::err_literal_operator_param)
16175 Diag(Param->getSourceRange().getBegin(),
16176 diag::err_literal_operator_invalid_param)
16177 << ParamType << Param->getSourceRange();
16186 QualType FirstParamType = (*Param)->getType().getUnqualifiedType();
16193 Diag((*Param)->getSourceRange().getBegin(),
16194 diag::err_literal_operator_param)
16195 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16202 Diag((*Param)->getSourceRange().getBegin(),
16203 diag::err_literal_operator_param)
16204 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16217 Diag((*Param)->getSourceRange().getBegin(),
16218 diag::err_literal_operator_param)
16219 << FirstParamType <<
"'const char *'" << (*Param)->getSourceRange();
16227 QualType SecondParamType = (*Param)->getType().getUnqualifiedType();
16229 Diag((*Param)->getSourceRange().getBegin(),
16230 diag::err_literal_operator_param)
16232 << (*Param)->getSourceRange();
16236 Diag(FnDecl->
getLocation(), diag::err_literal_operator_bad_param_count);
16245 if (Param->hasDefaultArg()) {
16246 Diag(Param->getDefaultArgRange().getBegin(),
16247 diag::err_literal_operator_default_argument)
16248 << Param->getDefaultArgRange();
16253 StringRef LiteralName
16255 if (LiteralName[0] !=
'_' &&
16256 !getSourceManager().isInSystemHeader(FnDecl->
getLocation())) {
16278 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_not_ascii)
16287 else if (Lang ==
"C++")
16290 Diag(LangStr->
getExprLoc(), diag::err_language_linkage_spec_unknown)
16310 if (getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
16312 PushGlobalModuleFragment(ExternLoc,
true);
16322 CurContext->addDecl(D);
16323 PushDeclContext(S, D);
16342 if (getLangOpts().CPlusPlusModules && getCurrentModule() &&
16343 getCurrentModule()->isGlobalModule() && getCurrentModule()->
Parent)
16344 PopGlobalModuleFragment();
16347 return LinkageSpec;
16356 ProcessDeclAttributeList(S, ED, AttrList);
16358 CurContext->addDecl(ED);
16384 Diag(Loc, diag::err_catch_rvalue_ref);
16389 Diag(Loc, diag::err_catch_variably_modified) << ExDeclType;
16395 unsigned DK = diag::err_catch_incomplete;
16397 BaseType = Ptr->getPointeeType();
16399 DK = diag::err_catch_incomplete_ptr;
16402 BaseType = Ref->getPointeeType();
16404 DK = diag::err_catch_incomplete_ref;
16406 if (!
Invalid && (Mode == 0 || !BaseType->isVoidType()) &&
16407 !BaseType->isDependentType() && RequireCompleteType(Loc, BaseType, DK))
16410 if (!
Invalid && Mode != 1 && BaseType->isSizelessType()) {
16411 Diag(Loc, diag::err_catch_sizeless) << (Mode == 2 ? 1 : 0) << BaseType;
16416 RequireNonAbstractType(Loc, ExDeclType,
16417 diag::err_abstract_type_in_decl,
16418 AbstractVariableType))
16428 if (T->isObjCObjectType()) {
16429 Diag(Loc, diag::err_objc_object_catch);
16431 }
else if (T->isObjCObjectPointerType()) {
16434 Diag(Loc, diag::warn_objc_pointer_cxx_catch_fragile);
16443 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(ExDecl))
16450 *
this, ExpressionEvaluationContext::PotentiallyEvaluated);
16468 Expr *opaqueValue =
16479 Expr *init = MaybeCreateExprWithCleanups(construct);
16484 FinalizeVarWithDestructor(ExDecl,
recordType);
16503 UPPC_ExceptionType)) {
16511 LookupOrdinaryName,
16512 ForVisibleRedeclaration)) {
16516 assert(!S->isDeclScope(PrevDecl));
16517 if (isDeclInScope(PrevDecl, CurContext, S)) {
16520 Diag(PrevDecl->getLocation(), diag::note_previous_definition);
16522 }
else if (PrevDecl->isTemplateParameter())
16533 VarDecl *ExDecl = BuildExceptionDeclaration(
16540 PushOnScopeChains(ExDecl, S);
16542 CurContext->addDecl(ExDecl);
16544 ProcessDeclAttributes(S, ExDecl, D);
16550 Expr *AssertMessageExpr,
16555 if (DiagnoseUnexpandedParameterPack(AssertExpr, UPPC_StaticAssertExpression))
16558 return BuildStaticAssertDeclaration(StaticAssertLoc, AssertExpr,
16559 AssertMessage, RParenLoc,
false);
16567 assert(AssertExpr !=
nullptr &&
"Expected non-null condition");
16572 ExprResult Converted = PerformContextuallyConvertToBool(AssertExpr);
16577 ActOnFinishFullExpr(Converted.
get(), StaticAssertLoc,
16583 AssertExpr = FullAssertExpr.
get();
16586 if (!Failed && VerifyIntegerConstantExpression(
16588 diag::err_static_assert_expression_is_not_constant)
16592 if (!Failed && !
Cond) {
16594 llvm::raw_svector_ostream Msg(MsgBuffer);
16595 if (AssertMessage) {
16597 if (MsgStr->isOrdinary())
16598 Msg << MsgStr->getString();
16600 MsgStr->printPretty(Msg,
nullptr, getPrintingPolicy());
16603 Expr *InnerCond =
nullptr;
16604 std::string InnerCondDescription;
16605 std::tie(InnerCond, InnerCondDescription) =
16606 findFailedBooleanCondition(Converted.
get());
16607 if (InnerCond && isa<ConceptSpecializationExpr>(InnerCond)) {
16610 Diag(StaticAssertLoc, diag::err_static_assert_failed)
16614 DiagnoseUnsatisfiedConstraint(Satisfaction);
16615 }
else if (InnerCond && !isa<CXXBoolLiteralExpr>(InnerCond)
16616 && !isa<IntegerLiteral>(InnerCond)) {
16617 Diag(StaticAssertLoc, diag::err_static_assert_requirement_failed)
16618 << InnerCondDescription << !AssertMessage
16621 Diag(StaticAssertLoc, diag::err_static_assert_failed)
16627 ExprResult FullAssertExpr = ActOnFinishFullExpr(AssertExpr, StaticAssertLoc,
16633 AssertExpr = FullAssertExpr.
get();
16637 AssertExpr, AssertMessage, RParenLoc,
16640 CurContext->addDecl(
Decl);
16650 assert(TSInfo &&
"NULL TypeSourceInfo for friend type declaration");
16660 if (!CodeSynthesisContexts.empty()) {
16665 if (!T->isElaboratedTypeSpecifier()) {
16676 diag::warn_cxx98_compat_unelaborated_friend_type :
16677 diag::ext_unelaborated_friend_type)
16685 diag::warn_cxx98_compat_nonclass_type_friend :
16686 diag::ext_nonclass_type_friend)
16690 }
else if (T->getAs<
EnumType>()) {
16693 diag::warn_cxx98_compat_enum_friend :
16694 diag::ext_enum_friend)
16705 if (getLangOpts().
CPlusPlus11 && LocStart != FriendLoc)
16706 Diag(FriendLoc, diag::err_friend_not_first_in_declaration) << T;
16727 bool IsMemberSpecialization =
false;
16731 MatchTemplateParametersToScopeSpecifier(
16732 TagLoc, NameLoc, SS,
nullptr, TempParamLists,
true,
16733 IsMemberSpecialization,
Invalid)) {
16734 if (TemplateParams->size() > 0) {
16739 return CheckClassTemplate(S, TagSpec, TUK_Friend, TagLoc, SS, Name,
16742 FriendLoc, TempParamLists.size() - 1,
16743 TempParamLists.data()).get();
16746 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
16748 IsMemberSpecialization =
true;
16754 bool isAllExplicitSpecializations =
true;
16755 for (
unsigned I = TempParamLists.size(); I-- > 0; ) {
16756 if (TempParamLists[I]->size()) {
16757 isAllExplicitSpecializations =
false;
16767 if (isAllExplicitSpecializations) {
16769 bool Owned =
false;
16770 bool IsDependent =
false;
16771 return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc,
16785 QualType T = CheckTypenameType(Keyword, TagLoc, QualifierLoc,
16791 if (isa<DependentNameType>(T)) {
16805 TSI, FriendLoc, TempParamLists);
16807 CurContext->addDecl(Friend);
16811 assert(SS.
isNotEmpty() &&
"valid templated tag with no SS and no direct?");
16818 Diag(NameLoc, diag::warn_template_qualified_friend_unsupported)
16829 TSI, FriendLoc, TempParamLists);
16832 CurContext->addDecl(Friend);
16887 DeclaratorContext::Member);
16893 if (DiagnoseUnexpandedParameterPack(Loc, TSI, UPPC_FriendDeclaration))
16910 if (TempParams.size() && !T->isElaboratedTypeSpecifier()) {
16911 Diag(Loc, diag::err_tagless_friend_type_template)
16928 if (!TempParams.empty())
16940 CurContext->addDecl(D);
16966 Diag(Loc, diag::err_unexpected_friend);
16993 if (DiagnoseUnexpandedParameterPack(Loc, TInfo, UPPC_FriendDeclaration) ||
16994 DiagnoseUnexpandedParameterPack(NameInfo, UPPC_FriendDeclaration) ||
16995 DiagnoseUnexpandedParameterPack(SS, UPPC_FriendDeclaration))
17001 Scope *DCScope = S;
17003 ForExternalRedeclaration);
17011 (FunctionContainingLocalClass =
17012 cast<CXXRecordDecl>(CurContext)->isLocalClass())) {
17024 DCScope = S->getFnParent();
17027 Previous.clear(LookupLocalFriendName);
17034 DC =
Previous.getRepresentativeDecl()->getDeclContext();
17038 DC = FunctionContainingLocalClass;
17040 adjustContextForLocalExternDecl(DC);
17060 bool isTemplateId =
17078 LookupQualifiedName(
Previous, LookupDC);
17085 if (isTemplateId) {
17086 if (isa<TranslationUnitDecl>(LookupDC))
break;
17093 DCScope = getScopeForDeclContext(S, DC);
17099 DC = computeDeclContext(SS);
17100 if (!DC)
return nullptr;
17102 if (RequireCompleteDeclContext(SS, DC))
return nullptr;
17104 LookupQualifiedName(
Previous, DC);
17108 if (DC->
Equals(CurContext))
17111 diag::warn_cxx98_compat_friend_is_member :
17112 diag::err_friend_is_member);
17148 assert(isa<CXXRecordDecl>(DC) &&
"friend declaration not in class?");
17154 case UnqualifiedIdKind::IK_ConstructorTemplateId:
17155 case UnqualifiedIdKind::IK_ConstructorName:
17158 case UnqualifiedIdKind::IK_DestructorName:
17161 case UnqualifiedIdKind::IK_ConversionFunctionId:
17164 case UnqualifiedIdKind::IK_DeductionGuideName:
17167 case UnqualifiedIdKind::IK_Identifier:
17168 case UnqualifiedIdKind::IK_ImplicitSelfParam:
17169 case UnqualifiedIdKind::IK_LiteralOperatorId:
17170 case UnqualifiedIdKind::IK_OperatorFunctionId:
17171 case UnqualifiedIdKind::IK_TemplateId:
17175 if (DiagArg >= 0) {
17176 Diag(Loc, diag::err_introducing_special_friend) << DiagArg;
17187 DCScope = &FakeDCScope;
17190 bool AddToScope =
true;
17192 TemplateParams, AddToScope);
17193 if (!ND)
return nullptr;
17207 if (!CurContext->isDependentContext()) {
17210 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
17211 PushOnScopeChains(ND, EnclosingScope,
false);
17218 CurContext->addDecl(FrD);
17223 if (DC->
isRecord()) CheckFriendAccess(ND);
17227 FD = FTD->getTemplatedDecl();
17240 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_redeclared);
17242 diag::note_previous_declaration);
17244 Diag(FD->
getLocation(), diag::err_friend_decl_with_def_arg_must_be_def);
17249 Diag(FD->
getLocation(), diag::warn_template_qualified_friend_unsupported)
17256 warnOnReservedIdentifier(ND);
17262 AdjustDeclIfTemplate(Dcl);
17264 FunctionDecl *Fn = dyn_cast_or_null<FunctionDecl>(Dcl);
17266 Diag(DelLoc, diag::err_deleted_non_function);
17277 Prev->getPreviousDecl()) &&
17278 !Prev->isDefined()) {
17279 Diag(DelLoc, diag::err_deleted_decl_not_first);
17280 Diag(Prev->getLocation().isInvalid() ? DelLoc : Prev->getLocation(),
17281 Prev->isImplicit() ? diag::note_previous_implicit_declaration
17282 : diag::note_previous_declaration);
17305 Diag(DelLoc, diag::err_deleted_main);
17317 auto *FD = dyn_cast<FunctionDecl>(Dcl);
17319 if (
auto *FTD = dyn_cast<FunctionTemplateDecl>(Dcl)) {
17320 if (getDefaultedFunctionKind(FTD->getTemplatedDecl()).isComparison()) {
17321 Diag(DefaultLoc, diag::err_defaulted_comparison_template);
17326 Diag(DefaultLoc, diag::err_default_special_members)
17327 << getLangOpts().CPlusPlus20;
17337 (!FD->isDependentContext() ||
17338 (!isa<CXXConstructorDecl>(FD) &&
17340 Diag(DefaultLoc, diag::err_default_special_members)
17341 << getLangOpts().CPlusPlus20;
17348 DefKind.
asComparison() != DefaultedComparisonKind::ThreeWay) {
17350 ? diag::warn_cxx17_compat_defaulted_comparison
17351 : diag::ext_defaulted_comparison);
17354 FD->setDefaulted();
17355 FD->setExplicitlyDefaulted();
17358 if (FD->isDependentContext())
17364 FD->setWillHaveBody(
false);
17377 if (isa<CXXMethodDecl>(FD)) {
17379 if (
const FunctionDecl *Pattern = FD->getTemplateInstantiationPattern())
17388 if (CheckExplicitlyDefaultedComparison(
nullptr, FD, DefKind.
asComparison()))
17391 DefineDefaultedComparison(DefaultLoc, FD, DefKind.
asComparison());
17395 if (CheckExplicitlyDefaultedSpecialMember(MD, DefKind.
asSpecialMember()))
17403 for (
Stmt *SubStmt : S->children()) {
17406 if (isa<ReturnStmt>(SubStmt))
17407 Self.
Diag(SubStmt->getBeginLoc(),
17408 diag::err_return_in_constructor_handler);
17409 if (!isa<Expr>(SubStmt))
17415 for (
unsigned I = 0, E = TryBlock->
getNumHandlers(); I != E; ++I) {
17423 switch (BodyKind) {
17424 case FnBodyKind::Delete:
17425 SetDeclDeleted(D, Loc);
17427 case FnBodyKind::Default:
17428 SetDeclDefaulted(D, Loc);
17430 case FnBodyKind::Other:
17432 "Parsed function body should be '= delete;' or '= default;'");
17442 for (
unsigned I = 0, E = OldFT->
getNumParams(); I != E; ++I)
17446 !NewFT->getExtParameterInfo(I).isNoEscape()) {
17448 diag::warn_overriding_method_missing_noescape);
17450 diag::note_overridden_marked_noescape);
17455 const auto *OldCSA = Old->
getAttr<CodeSegAttr>();
17456 const auto *NewCSA = New->
getAttr<CodeSegAttr>();
17457 if ((NewCSA || OldCSA) &&
17458 (!OldCSA || !NewCSA || NewCSA->getName() != OldCSA->getName())) {
17467 if (NewCC == OldCC)
17478 diag::err_conflicting_overriding_cc_attributes)
17504 if (NewRT->getTypeClass() == OldRT->getTypeClass()) {
17512 if (NewClassTy.
isNull()) {
17514 diag::err_different_return_type_for_overriding_virtual_function)
17530 if (!RT->isBeingDefined() &&
17531 RequireCompleteType(New->
getLocation(), NewClassTy,
17532 diag::err_covariant_return_incomplete,
17538 if (!IsDerivedFrom(New->
getLocation(), NewClassTy, OldClassTy)) {
17548 if (CheckDerivedToBaseConversion(
17549 NewClassTy, OldClassTy,
17550 diag::err_covariant_return_inaccessible_base,
17551 diag::err_covariant_return_ambiguous_derived_to_base_conv,
17567 diag::err_covariant_return_type_different_qualifications)
17579 diag::err_covariant_return_type_class_type_more_qualified)
17598 Method->setRangeEnd(EndLoc);
17600 if (Method->isVirtual() || Method->getParent()->isDependentContext()) {
17605 if (!Method->isInvalidDecl())
17606 Diag(Method->getLocation(), diag::err_non_virtual_pure)
17607 << Method->getDeclName() << InitRange;
17614 else if (
auto *M = dyn_cast<CXXMethodDecl>(D))
17615 CheckPureMethod(M, ZeroLoc);
17623 if (
const VarDecl *Var = dyn_cast_or_null<VarDecl>(D))
17624 return Var->hasGlobalStorage();
17652 PushExpressionEvaluationContext(
17653 ExpressionEvaluationContext::PotentiallyEvaluated, D);
17663 PopExpressionEvaluationContext();
17666 ExitDeclaratorContext(S);
17678 "Parser allowed 'typedef' as storage class of condition decl.");
17680 Decl *Dcl = ActOnDeclarator(S, D);
17684 if (isa<FunctionDecl>(Dcl)) {
17694 if (!ExternalSource)
17698 ExternalSource->ReadUsedVTables(VTables);
17700 for (
unsigned I = 0,
N = VTables.size(); I !=
N; ++I) {
17701 llvm::DenseMap<CXXRecordDecl *, bool>::iterator Pos
17702 = VTablesUsed.find(VTables[I].Record);
17704 if (Pos != VTablesUsed.end()) {
17705 if (!Pos->second && VTables[I].DefinitionRequired)
17706 Pos->second =
true;
17710 VTablesUsed[VTables[I].Record] = VTables[I].DefinitionRequired;
17711 NewUses.push_back(
VTableUse(VTables[I].Record, VTables[I].Location));
17714 VTableUses.insert(VTableUses.begin(), NewUses.begin(), NewUses.end());
17718 bool DefinitionRequired) {
17721 if (!Class->isDynamicClass() || Class->isDependentContext() ||
17722 CurContext->isDependentContext() || isUnevaluatedContext())
17726 if (TUKind !=
TU_Prefix && LangOpts.OpenMP && LangOpts.OpenMPIsDevice &&
17727 !isInOpenMPDeclareTargetContext() &&
17728 !isInOpenMPTargetExecutionDirective()) {
17729 if (!DefinitionRequired)
17730 MarkVirtualMembersReferenced(Loc, Class);
17735 LoadExternalVTableUses();
17736 Class = Class->getCanonicalDecl();
17737 std::pair<llvm::DenseMap<CXXRecordDecl *, bool>::iterator,
bool>
17738 Pos = VTablesUsed.insert(std::make_pair(Class, DefinitionRequired));
17743 if (DefinitionRequired && !Pos.first->second) {
17744 Pos.first->second =
true;
17757 if (Class->hasUserDeclaredDestructor() && !DD->
isDefined()) {
17762 CheckDestructor(DD);
17764 MarkFunctionReferenced(Loc, Class->getDestructor());
17773 if (Class->isLocalClass())
17774 MarkVirtualMembersReferenced(Loc, Class);
17776 VTableUses.push_back(std::make_pair(Class, Loc));
17780 LoadExternalVTableUses();
17781 if (VTableUses.empty())
17788 bool DefinedAnything =
false;
17789 for (
unsigned I = 0; I != VTableUses.size(); ++I) {
17798 bool DefineVTable =
true;
17804 if (KeyFunction && !KeyFunction->
hasBody()) {
17806 DefineVTable =
false;
17811 "Instantiations don't have key functions");
17813 }
else if (!KeyFunction) {
17818 bool IsExplicitInstantiationDeclaration =
17820 for (
auto R : Class->redecls()) {
17824 IsExplicitInstantiationDeclaration =
true;
17826 IsExplicitInstantiationDeclaration =
false;
17831 if (IsExplicitInstantiationDeclaration)
17832 DefineVTable =
false;
17838 if (!DefineVTable) {
17839 MarkVirtualMemberExceptionSpecsNeeded(Loc, Class);
17846 DefinedAnything =
true;
17847 MarkVirtualMembersReferenced(Loc, Class);
17849 if (VTablesUsed[Canonical])
17850 Consumer.HandleVTable(Class);
17859 if (!KeyFunction || (KeyFunction->
hasBody(KeyFunctionDef) &&
17861 Diag(Class->getLocation(), diag::warn_weak_vtable) << Class;
17864 VTableUses.clear();
17866 return DefinedAnything;
17871 for (
const auto *I : RD->
methods())
17872 if (I->isVirtual() && !I->isPure())
17878 bool ConstexprOnly) {
17882 for (CXXFinalOverriderMap::const_iterator I = FinalOverriders.begin(),
17883 E = FinalOverriders.end();
17886 OE = I->second.end();
17888 assert(OI->second.size() > 0 &&
"no final overrider");
17894 MarkFunctionReferenced(Loc, Overrider);
17902 for (
const auto &I : RD->
bases()) {
17905 if (
Base->getNumVBases() == 0)
17907 MarkVirtualMembersReferenced(Loc,
Base);
17918 CollectIvarsToConstructOrDestruct(OID, ivars);
17922 for (
unsigned i = 0; i < ivars.size(); i++) {
17924 if (Field->isInvalidDecl())
17934 InitSeq.
Perform(*
this, InitEntity, InitKind, None);
17935 MemberInit = MaybeCreateExprWithCleanups(MemberInit);
17946 AllToInit.push_back(
Member);
17954 MarkFunctionReferenced(Field->getLocation(), Destructor);
17955 CheckDestructorAccess(Field->getLocation(), Destructor,
17956 PDiag(diag::err_access_dtor_ivar)
17962 AllToInit.data(), AllToInit.size());
17981 (void)Target->
hasBody(FNTarget);
17983 cast_or_null<CXXConstructorDecl>(FNTarget));
17990 if (!Current.insert(Canonical).second)
17994 if (!Target || !Target->isDelegatingConstructor() ||
17995 Target->isInvalidDecl() || Valid.count(TCanonical)) {
17996 Valid.insert(Current.begin(), Current.end());
17999 }
else if (TCanonical == Canonical ||
Invalid.count(TCanonical) ||
18000 Current.count(TCanonical)) {
18002 if (!
Invalid.count(TCanonical)) {
18004 diag::warn_delegating_ctor_cycle)
18008 if (TCanonical != Canonical)
18009 S.
Diag(Target->getLocation(), diag::note_it_delegates_to);
18012 while (
C->getCanonicalDecl() != Canonical) {
18014 (void)
C->getTargetConstructor()->
hasBody(FNTarget);
18015 assert(FNTarget &&
"Ctor cycle through bodiless function");
18019 S.
Diag(
C->getLocation(), diag::note_which_delegates_to);
18023 Invalid.insert(Current.begin(), Current.end());
18034 for (DelegatingCtorDeclsType::iterator
18035 I = DelegatingCtorDecls.begin(ExternalSource),
18036 E = DelegatingCtorDecls.end();
18040 for (
auto CI =
Invalid.begin(), CE =
Invalid.end(); CI != CE; ++CI)
18041 (*CI)->setInvalidDecl();
18050 explicit FindCXXThisExpr(
Sema &S) : S(S) { }
18078 FindCXXThisExpr Finder(*
this);
18086 if (checkThisInStaticMemberFunctionExceptionSpec(Method))
18090 if (
Expr *E = Method->getTrailingRequiresClause())
18091 if (!Finder.TraverseStmt(E))
18094 return checkThisInStaticMemberFunctionAttributes(Method);
18108 FindCXXThisExpr Finder(*
this);
18130 if (!Finder.TraverseType(E))
18140 FindCXXThisExpr Finder(*
this);
18143 for (
const auto *A : Method->attrs()) {
18145 Expr *Arg =
nullptr;
18147 if (
const auto *G = dyn_cast<GuardedByAttr>(A))
18149 else if (
const auto *G = dyn_cast<PtGuardedByAttr>(A))
18151 else if (
const auto *AA = dyn_cast<AcquiredAfterAttr>(A))
18152 Args = llvm::makeArrayRef(AA->args_begin(), AA->args_size());
18153 else if (
const auto *AB = dyn_cast<AcquiredBeforeAttr>(A))
18154 Args = llvm::makeArrayRef(AB->args_begin(), AB->args_size());
18155 else if (
const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) {
18156 Arg = ETLF->getSuccessValue();
18157 Args = llvm::makeArrayRef(ETLF->args_begin(), ETLF->args_size());
18158 }
else if (
const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) {
18159 Arg = STLF->getSuccessValue();
18160 Args = llvm::makeArrayRef(STLF->args_begin(), STLF->args_size());
18161 }
else if (
const auto *LR = dyn_cast<LockReturnedAttr>(A))
18162 Arg = LR->getArg();
18163 else if (
const auto *LE = dyn_cast<LocksExcludedAttr>(A))
18164 Args = llvm::makeArrayRef(LE->args_begin(), LE->args_size());
18165 else if (
const auto *RC = dyn_cast<RequiresCapabilityAttr>(A))
18166 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
18167 else if (
const auto *AC = dyn_cast<AcquireCapabilityAttr>(A))
18168 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
18169 else if (
const auto *AC = dyn_cast<TryAcquireCapabilityAttr>(A))
18170 Args = llvm::makeArrayRef(AC->args_begin(), AC->args_size());
18171 else if (
const auto *RC = dyn_cast<ReleaseCapabilityAttr>(A))
18172 Args = llvm::makeArrayRef(RC->args_begin(), RC->args_size());
18174 if (Arg && !Finder.TraverseStmt(Arg))
18177 for (
unsigned I = 0,
N = Args.size(); I !=
N; ++I) {
18178 if (!Finder.TraverseStmt(Args[I]))
18192 Exceptions.clear();
18195 Exceptions.reserve(DynamicExceptions.size());
18196 for (
unsigned ei = 0, ee = DynamicExceptions.size(); ei != ee; ++ei) {
18198 QualType ET = GetTypeFromParser(DynamicExceptions[ei]);
18203 if (!Unexpanded.empty()) {
18205 DynamicExceptionRanges[ei].getBegin(), UPPC_ExceptionType,
18213 if (!CheckSpecifiedExceptionType(ET, DynamicExceptionRanges[ei]))
18214 Exceptions.push_back(ET);
18224 "Parser should have made sure that the expression is boolean");
18225 if (IsTopLevel && DiagnoseUnexpandedParameterPack(NoexceptExpr)) {
18240 Expr *NoexceptExpr) {
18246 MethodD = FunTmpl->getTemplatedDecl();
18255 checkExceptionSpecification(
true, EST, DynamicExceptions,
18256 DynamicExceptionRanges, NoexceptExpr, Exceptions,
18262 if (Method->isStatic())
18263 checkThisInStaticMemberFunctionExceptionSpec(Method);
18265 if (Method->isVirtual()) {
18268 CheckOverridingFunctionExceptionSpec(Method, O);
18282 Diag(DeclStart, diag::err_anonymous_property);
18290 CheckExtraCXXDefaultArguments(D);
18293 UPPC_DataMemberType)) {
18304 << getLangOpts().CPlusPlus17;
18307 diag::err_invalid_thread)
18313 ForVisibleRedeclaration);
18315 switch (
Previous.getResultKind()) {
18322 PrevDecl =
Previous.getRepresentativeDecl();
18335 PrevDecl =
nullptr;
18338 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
18339 PrevDecl =
nullptr;
18346 ProcessDeclAttributes(TUScope, NewPD, D);
18350 Record->setInvalidDecl();
18359 PushOnScopeChains(NewPD, S);
18361 Record->addDecl(NewPD);
18368 auto &Info = InventedParameterInfos.emplace_back();
18372 if (!ExplicitLists.empty()) {
18373 bool IsMemberSpecialization, IsInvalid;
18374 ExplicitParams = MatchTemplateParametersToScopeSpecifier(
18377 ExplicitLists,
false, IsMemberSpecialization, IsInvalid,
18380 if (ExplicitParams) {
18381 Info.AutoTemplateParameterDepth = ExplicitParams->
getDepth();
18382 llvm::append_range(Info.TemplateParams, *ExplicitParams);
18383 Info.NumExplicitTemplateParams = ExplicitParams->
size();
18385 Info.AutoTemplateParameterDepth = TemplateParameterDepth;
18386 Info.NumExplicitTemplateParams = 0;
18391 auto &FSI = InventedParameterInfos.back();
18392 if (FSI.TemplateParams.size() > FSI.NumExplicitTemplateParams) {
18393 if (FSI.NumExplicitTemplateParams != 0) {
18397 TemplateParameterList::Create(
18404 TemplateParameterList::Create(
18409 InventedParameterInfos.pop_back();
Defines the clang::ASTContext interface.
This file provides some common utility functions for processing Lambda related AST Constructs.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool CheckLiteralType(EvalInfo &Info, const Expr *E, const LValue *This=nullptr)
Check that this core constant expression is of literal type, and if not, produce an appropriate diagn...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
static bool CheckConstraintSatisfaction(Sema &S, const NamedDecl *Template, ArrayRef< const Expr * > ConstraintExprs, ArrayRef< TemplateArgument > TemplateArgs, SourceRange TemplateIDRange, ConstraintSatisfaction &Satisfaction)
static Sema::SpecialMemberOverloadResult lookupCallFromSpecialMember(Sema &S, CXXRecordDecl *Class, Sema::CXXSpecialMember CSM, unsigned FieldQuals, bool ConstRHS)
Look up the special member function that would be called by a special member function for a subobject...
static void checkMoveAssignmentForRepeatedMove(Sema &S, CXXRecordDecl *Class, SourceLocation CurrentLocation)
Check if we're implicitly defining a move assignment operator for a class with virtual bases.
static void checkMethodTypeQualifiers(Sema &S, Declarator &D, unsigned DiagID)
static void DelegatingCycleHelper(CXXConstructorDecl *Ctor, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Valid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Invalid, llvm::SmallPtrSet< CXXConstructorDecl *, 4 > &Current, Sema &S)
static bool CheckConstexprFunctionBody(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *Body, Sema::CheckConstexprKind Kind)
Check the body for the given constexpr function declaration only contains the permitted types of stat...
llvm::SmallPtrSet< QualType, 4 > IndirectBaseSet
Use small set to collect indirect bases.
static void checkCUDADeviceBuiltinSurfaceClassTemplate(Sema &S, CXXRecordDecl *Class)
static bool checkVectorDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const VectorType *VT)
static void SearchForReturnInStmt(Sema &Self, Stmt *S)
static void extendRight(SourceRange &R, SourceRange After)
static void DiagnoseNamespaceInlineMismatch(Sema &S, SourceLocation KeywordLoc, SourceLocation Loc, IdentifierInfo *II, bool *IsInline, NamespaceDecl *PrevNS)
Diagnose a mismatch in 'inline' qualifiers when a namespace is reopened.
static bool checkTrivialClassMembers(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, bool ConstArg, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the members of a class type allow a special member to be trivial.
static Sema::ImplicitExceptionSpecification ComputeDefaultedSpecialMemberExceptionSpec(Sema &S, SourceLocation Loc, CXXMethodDecl *MD, Sema::CXXSpecialMember CSM, Sema::InheritedConstructorInfo *ICI)
static bool RefersToRValueRef(Expr *MemRef)
static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy)
static bool isVirtualDirectBase(CXXRecordDecl *Derived, CXXRecordDecl *Base)
Determine whether a direct base class is a virtual base class.
static IsTupleLike isTupleLike(Sema &S, SourceLocation Loc, QualType T, llvm::APSInt &Size)
#define CheckPolymorphic(Type)
static bool findCircularInheritance(const CXXRecordDecl *Class, const CXXRecordDecl *Current)
Determine whether the given class is a base class of the given class, including looking at dependent ...
static void BuildBasePathArray(const CXXBasePath &Path, CXXCastPath &BasePathArray)
static void CheckAbstractClassUsage(AbstractUsageInfo &Info, FunctionDecl *FD)
Check for invalid uses of an abstract type in a function declaration.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for record diagnostic message.
static void extendLeft(SourceRange &R, SourceRange Before)
static bool canPassInRegisters(Sema &S, CXXRecordDecl *D, TargetInfo::CallingConvKind CCK)
Determine whether a type is permitted to be passed or returned in registers, per C++ [class....
static void lookupOperatorsForDefaultedComparison(Sema &Self, Scope *S, UnresolvedSetImpl &Operators, OverloadedOperatorKind Op)
Perform the unqualified lookups that might be needed to form a defaulted comparison function for the ...
static void diagnoseDeprecatedCopyOperation(Sema &S, CXXMethodDecl *CopyOp)
Diagnose an implicit copy operation for a class which is odr-used, but which is deprecated because th...
static void AddMostOverridenMethods(const CXXMethodDecl *MD, llvm::SmallPtrSetImpl< const CXXMethodDecl * > &Methods)
Add the most overridden methods from MD to Methods.
static bool CheckOperatorNewDeleteTypes(Sema &SemaRef, const FunctionDecl *FnDecl, CanQualType ExpectedResultType, CanQualType ExpectedFirstParamType, unsigned DependentParamTypeDiag, unsigned InvalidParamTypeDiag)
static DeclAccessPair findDecomposableBaseClass(Sema &S, SourceLocation Loc, const CXXRecordDecl *RD, CXXCastPath &BasePath)
Find the base class to decompose in a built-in decomposition of a class type.
static const void * GetKeyForBase(ASTContext &Context, QualType BaseType)
static Sema::ImplicitExceptionSpecification ComputeDefaultedComparisonExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD, Sema::DefaultedComparisonKind DCK)
static StmtResult buildSingleCopyAssignRecursively(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying, unsigned Depth=0)
Builds a statement that copies/moves the given entity from From to To.
static void checkCUDADeviceBuiltinTextureClassTemplate(Sema &S, CXXRecordDecl *Class)
static void AddInitializerToDiag(const Sema::SemaDiagnosticBuilder &Diag, const CXXCtorInitializer *Previous, const CXXCtorInitializer *Current)
static bool BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, CXXBaseSpecifier *BaseSpec, bool IsInheritedVirtualBase, CXXCtorInitializer *&CXXBaseInit)
static bool checkTupleLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, VarDecl *Src, QualType DecompType, const llvm::APSInt &TupleSize)
static void NoteIndirectBases(ASTContext &Context, IndirectBaseSet &Set, const QualType &Type)
Recursively add the bases of Type. Don't add Type itself.
static bool CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S, SmallVectorImpl< SourceLocation > &ReturnStmts, SourceLocation &Cxx1yLoc, SourceLocation &Cxx2aLoc, SourceLocation &Cxx2bLoc, Sema::CheckConstexprKind Kind)
Check the provided statement is allowed in a constexpr function definition.
static bool functionDeclHasDefaultArgument(const FunctionDecl *FD)
static bool CheckConstexprParameterTypes(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's parameter types are all literal types.
static bool findTrivialSpecialMember(Sema &S, CXXRecordDecl *RD, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, Sema::TrivialABIHandling TAH, CXXMethodDecl **Selected)
Perform lookup for a special member of the specified kind, and determine whether it is trivial.
static bool IsUsingDirectiveInToplevelContext(DeclContext *CurContext)
Determine whether a using statement is in a context where it will be apply in all contexts.
static CXXConstructorDecl * findUserDeclaredCtor(CXXRecordDecl *RD)
static bool checkMemberDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const CXXRecordDecl *OrigRD)
static void checkForMultipleExportedDefaultConstructors(Sema &S, CXXRecordDecl *Class)
static Expr * CastForMoving(Sema &SemaRef, Expr *E, QualType T=QualType())
static bool isNonlocalVariable(const Decl *D)
Determine whether the given declaration is a global variable or static data member.
static bool specialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, unsigned Quals, bool ConstRHS, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Is the special member function which would be selected to perform the specified operation on the spec...
static bool checkSimpleDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType, llvm::function_ref< ExprResult(SourceLocation, Expr *, unsigned)> GetInit)
static TemplateArgumentLoc getTrivialTypeTemplateArgument(Sema &S, SourceLocation Loc, QualType T)
static void findImplicitlyDeclaredEqualityComparisons(ASTContext &Ctx, CXXRecordDecl *RD, llvm::SmallVectorImpl< FunctionDecl * > &Spaceships)
Find the equality comparison functions that should be implicitly declared in a given class definition...
static void PopulateKeysForFields(FieldDecl *Field, SmallVectorImpl< const void * > &IdealInits)
ImplicitInitializerKind
ImplicitInitializerKind - How an implicit base or member initializer should initialize its base or me...
static NamespaceDecl * getNamespaceDecl(NamedDecl *D)
getNamespaceDecl - Returns the namespace a decl represents.
static bool checkArrayDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ConstantArrayType *CAT)
static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class)
static bool FindBaseInitializer(Sema &SemaRef, CXXRecordDecl *ClassDecl, QualType BaseType, const CXXBaseSpecifier *&DirectBaseSpec, const CXXBaseSpecifier *&VirtualBaseSpec)
Find the direct and/or virtual base specifiers that correspond to the given base type,...
static bool checkLiteralOperatorTemplateParameterList(Sema &SemaRef, FunctionTemplateDecl *TpDecl)
static ClassTemplateDecl * LookupStdInitializerList(Sema &S, SourceLocation Loc)
static bool CheckOperatorNewDeclaration(Sema &SemaRef, const FunctionDecl *FnDecl)
static bool ReportOverrides(Sema &S, unsigned DiagID, const CXXMethodDecl *MD, llvm::function_ref< bool(const CXXMethodDecl *)> Report)
Report an error regarding overriding, along with any relevant overridden methods.
static bool CheckOperatorDeleteDeclaration(Sema &SemaRef, FunctionDecl *FnDecl)
static const void * GetKeyForMember(ASTContext &Context, CXXCtorInitializer *Member)
static std::string printTemplateArgs(const PrintingPolicy &PrintingPolicy, TemplateArgumentListInfo &Args, const TemplateParameterList *Params)
static bool CheckConstexprReturnType(Sema &SemaRef, const FunctionDecl *FD, Sema::CheckConstexprKind Kind)
Check whether a function's return type is a literal type.
static const ParsedAttr * getMSPropertyAttr(const ParsedAttributesView &list)
static void DiagnoseBaseOrMemInitializerOrder(Sema &SemaRef, const CXXConstructorDecl *Constructor, ArrayRef< CXXCtorInitializer * > Inits)
static Sema::ImplicitExceptionSpecification computeImplicitExceptionSpec(Sema &S, SourceLocation Loc, FunctionDecl *FD)
static bool isIncompleteOrZeroLengthArrayType(ASTContext &Context, QualType T)
Determine whether the given type is an incomplete or zero-lenfgth array type.
TrivialSubobjectKind
The kind of subobject we are checking for triviality.
@ TSK_CompleteObject
The object is actually the complete object.
@ TSK_Field
The subobject is a non-static data member.
@ TSK_BaseClass
The subobject is a base class.
static bool hasOneRealArgument(MultiExprArg Args)
Determine whether the given list arguments contains exactly one "real" (non-default) argument.
static StmtResult buildMemcpyForAssignmentOp(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &ToB, const ExprBuilder &FromB)
When generating a defaulted copy or move assignment operator, if a field should be copied with __buil...
static void DefineDefaultedFunction(Sema &S, FunctionDecl *FD, SourceLocation DefaultLoc)
static bool BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, ImplicitInitializerKind ImplicitInitKind, FieldDecl *Field, IndirectFieldDecl *Indirect, CXXCtorInitializer *&CXXMemberInit)
static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info, FieldDecl *Field, IndirectFieldDecl *Indirect=nullptr)
static CXXBaseSpecifier * findDirectBaseWithType(CXXRecordDecl *Derived, QualType DesiredBase, bool &AnyDependentBases)
Find the base specifier for a base class with the given type.
static bool lookupStdTypeTraitMember(Sema &S, LookupResult &TraitMemberLookup, SourceLocation Loc, StringRef Trait, TemplateArgumentListInfo &Args, unsigned DiagID)
static bool checkTrivialSubobjectCall(Sema &S, SourceLocation SubobjLoc, QualType SubType, bool ConstRHS, Sema::CXXSpecialMember CSM, TrivialSubobjectKind Kind, Sema::TrivialABIHandling TAH, bool Diagnose)
Check whether the special member selected for a given type would be trivial.
static StmtResult buildSingleCopyAssign(Sema &S, SourceLocation Loc, QualType T, const ExprBuilder &To, const ExprBuilder &From, bool CopyingBaseSubobject, bool Copying)
static FunctionProtoType::ExtProtoInfo getImplicitMethodEPI(Sema &S, CXXMethodDecl *MD)
static QualType getTupleLikeElementType(Sema &S, SourceLocation Loc, unsigned I, QualType T)
static bool defaultedSpecialMemberIsConstexpr(Sema &S, CXXRecordDecl *ClassDecl, Sema::CXXSpecialMember CSM, bool ConstArg, CXXConstructorDecl *InheritedCtor=nullptr, Sema::InheritedConstructorInfo *Inherited=nullptr)
Determine whether the specified special member function would be constexpr if it were implicitly defi...
static bool checkComplexDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const ComplexType *CT)
static bool TryNamespaceTypoCorrection(Sema &S, LookupResult &R, Scope *Sc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
static bool InitializationHasSideEffects(const FieldDecl &FD)
static bool CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef, const FunctionDecl *FnDecl)
static bool checkArrayLikeDecomposition(Sema &S, ArrayRef< BindingDecl * > Bindings, ValueDecl *Src, QualType DecompType, const llvm::APSInt &NumElems, QualType ElemType)
static bool CheckConstexprDeclStmt(Sema &SemaRef, const FunctionDecl *Dcl, DeclStmt *DS, SourceLocation &Cxx1yLoc, Sema::CheckConstexprKind Kind)
Check the given declaration statement is legal within a constexpr function body.
static bool IsEquivalentForUsingDecl(ASTContext &Context, NamedDecl *D1, NamedDecl *D2)
Determine whether a using declaration considers the given declarations as "equivalent",...
static TemplateArgumentLoc getTrivialIntegralTemplateArgument(Sema &S, SourceLocation Loc, QualType T, uint64_t I)
static bool CheckConstexprDestructorSubobjects(Sema &SemaRef, const CXXDestructorDecl *DD, Sema::CheckConstexprKind Kind)
Determine whether a destructor cannot be constexpr due to.
static bool CheckConstexprCtorInitializer(Sema &SemaRef, const FunctionDecl *Dcl, FieldDecl *Field, llvm::SmallSet< Decl *, 16 > &Inits, bool &Diagnosed, Sema::CheckConstexprKind Kind)
Check that the given field is initialized within a constexpr constructor.
static bool isProvablyNotDerivedFrom(Sema &SemaRef, CXXRecordDecl *Record, const BaseSet &Bases)
Determines if the given class is provably not derived from all of the prospective base classes.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt, NamedDecl *Dest)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
static void collectUnexpandedParameterPacks(Sema &S, TemplateParameterList *Params, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
static bool DiagnoseUnexpandedParameterPacks(Sema &S, TemplateTemplateParmDecl *TTP)
Check for unexpanded parameter packs within the template parameters of a template template parameter,...
static bool isInvalid(LocType Loc, bool *Invalid)
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TypeLoc interface and its subclasses.
Allows QualTypes to be sorted and hence used in maps and sets.
const NestedNameSpecifier * Specifier
__DEVICE__ void * memcpy(void *__a, const void *__b, size_t __c)
std::pair< CXXConstructorDecl *, bool > findConstructorForBase(CXXRecordDecl *Base, CXXConstructorDecl *Ctor) const
Find the constructor to use for inherited construction of a base class, and whether that base class c...
InheritedConstructorInfo(Sema &S, SourceLocation UseLoc, ConstructorUsingShadowDecl *Shadow)
virtual bool HandleTopLevelDecl(DeclGroupRef D)
HandleTopLevelDecl - Handle the specified top-level declaration.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
TranslationUnitDecl * getTranslationUnitDecl() const
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type.
unsigned getIntWidth(QualType T) const
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl.
DeclarationNameTable DeclarationNames
QualType getRecordType(const RecordDecl *Decl) const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CallingConv getDefaultCallingConvention(bool IsVariadic, bool IsCXXMethod, bool IsBuiltin=false) const
Retrieves the default calling convention for the current target.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or nullptr if there isn't on...
void Deallocate(void *Ptr) const
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
const LangOptions & getLangOpts() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
ComparisonCategories CompCategories
Types and expressions required to build C++2a three-way comparisons using operator<=>,...
bool hasSameTemplateName(const TemplateName &X, const TemplateName &Y) const
Determine whether the given template names refer to the same template.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated,...
const clang::PrintingPolicy & getPrintingPolicy() const
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
QualType getExceptionObjectType(QualType T) const
CanQualType UnsignedLongLongTy
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
llvm::APSInt MakeIntValue(uint64_t Value, QualType Type) const
Make an APSInt of the appropriate width and signedness for the given Value and integer Type.
const TargetInfo & getTargetInfo() const
QualType getAutoDeductType() const
C++11 deduction pattern for 'auto' type.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
NestedNameSpecifier * getCanonicalNestedNameSpecifier(NestedNameSpecifier *NNS) const
Retrieves the "canonical" nested name specifier for a given nested name specifier.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
Represents an access specifier followed by colon ':'.
static AccessSpecDecl * Create(ASTContext &C, AccessSpecifier AS, DeclContext *DC, SourceLocation ASLoc, SourceLocation ColonLoc)
Wrapper for source info for arrays.
TypeLoc getElementLoc() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
QualType getElementType() const
Attr - This represents one attribute.
attr::Kind getKind() const
Attr * clone(ASTContext &C) const
SourceLocation getLocation() const
@ AS_Keyword
__ptr16, alignas(...), etc.
Represents a C++ declaration that introduces decls from somewhere else.
unsigned shadow_size() const
Return the number of shadowed declarations associated with this using declaration.
void addShadowDecl(UsingShadowDecl *S)
shadow_iterator shadow_begin() const
void removeShadowDecl(UsingShadowDecl *S)
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static bool isCompoundAssignmentOp(Opcode Opc)
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
A binding in a decomposition declaration.
static BindingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id)
Wrapper for source info for block pointers.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
DeclContext::lookup_iterator Decls
The declarations found inside this base class subobject.
AccessSpecifier Access
The access along this inheritance path.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
std::list< CXXBasePath >::iterator paths_iterator
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isVirtual() const
Determines whether the base class is a virtual base class (or not).
QualType getType() const
Retrieves the type of the base class.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
AccessSpecifier getAccessSpecifier() const
Returns the access specifier for this base specifier.
CXXCatchStmt - This represents a C++ catch block.
Represents a call to a C++ constructor.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Expr * getArg(unsigned Arg)
Return the specified argument.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
Represents a C++ constructor within a class.
CXXConstructorDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isMoveConstructor(unsigned &TypeQuals) const
Determine whether this constructor is a move constructor (C++11 [class.copy]p3), which can be used to...
ExplicitSpecifier getExplicitSpecifier()
init_iterator init_begin()
Retrieve an iterator to the first initializer.
CXXConstructorDecl * getTargetConstructor() const
When this constructor delegates to another, retrieve the target.
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
InheritedConstructor getInheritedConstructor() const
Get the constructor that this inheriting constructor is based on.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), Expr *TrailingRequiresClause=nullptr)
Represents a C++ conversion function within a class.
QualType getConversionType() const
Returns the type that this conversion function is converting to.
Represents a C++ base or member initializer.
SourceRange getSourceRange() const LLVM_READONLY
Determine the source range covering the entire initializer.
SourceLocation getSourceLocation() const
Determine the source location of the initializer.
A use of a default initializer in a constructor or in aggregate initialization.
static CXXDefaultInitExpr * Create(const ASTContext &Ctx, SourceLocation Loc, FieldDecl *Field, DeclContext *UsedContext)
Field is the non-static data member whose default initializer is used by this expression.
Represents a C++ destructor within a class.
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, Expr *TrailingRequiresClause=nullptr)
A mapping from each virtual member function to its set of final overriders.
Represents a call to an inherited base class constructor from an inheriting constructor.
Represents a call to a member function that may be written either with member call syntax (e....
CXXMethodDecl * getMethodDecl() const
Retrieve the declaration of the called method.
Represents a static or instance method of a struct/union/class.
CXXMethodDecl * getMostRecentDecl()
overridden_method_range overridden_methods() const
unsigned size_overridden_methods() const
method_iterator begin_overridden_methods() const
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, Expr *TrailingRequiresClause=nullptr)
Qualifiers getMethodQualifiers() const
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
A call to an overloaded operator written using operator syntax.
Represents a C++ struct/union/class.
bool hasConstexprDefaultConstructor() const
Determine whether this class has a constexpr default constructor.
friend_range friends() const
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class....
bool isTriviallyCopyable() const
Determine whether this class is considered trivially copyable per (C++11 [class]p6).
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
bool isGenericLambda() const
Determine whether this class describes a generic lambda function object (i.e.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
bool hasUserDeclaredDestructor() const
Determine whether this class has a user-declared destructor.
bool isLiteral() const
Determine whether this class is a literal type.
bool implicitCopyConstructorHasConstParam() const
Determine whether an implicit copy constructor for this type would have a parameter with a const-qual...
bool defaultedDestructorIsDeleted() const
true if a defaulted destructor for this class would be deleted.
bool hasInheritedAssignment() const
Determine whether this class has a using-declaration that names a base class assignment operator.
bool allowConstDefaultInit() const
Determine whether declaring a const variable with this type is ok per core issue 253.
bool hasTrivialDestructorForCall() const
bool defaultedMoveConstructorIsDeleted() const
true if a defaulted move constructor for this class would be deleted.
bool hasUserDeclaredMoveAssignment() const
Determine whether this class has had a move assignment declared by the user.
bool defaultedDestructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation.
bool isLambda() const
Determine whether this class describes a lambda function object.
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12)
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
bool hasUserDeclaredCopyAssignment() const
Determine whether this class has a user-declared copy assignment operator.
bool isProvablyNotDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is provably not derived from the type Base.
method_range methods() const
CXXRecordDecl * getDefinition() const
bool needsOverloadResolutionForCopyAssignment() const
Determine whether we need to eagerly declare a defaulted copy assignment operator for this class.
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool defaultedDefaultConstructorIsConstexpr() const
Determine whether a defaulted default constructor for this class would be constexpr.
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class....
void setImplicitMoveAssignmentIsDeleted()
Set that we attempted to declare an implicit move assignment operator, but overload resolution failed...
bool hasConstexprDestructor() const
Determine whether this class has a constexpr destructor.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
unsigned getNumBases() const
Retrieves the number of base classes of this class.
bool defaultedCopyConstructorIsDeleted() const
true if a defaulted copy constructor for this class would be deleted.
bool hasTrivialCopyConstructorForCall() const
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths, bool LookupInDependent=false) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool lambdaIsDefaultConstructibleAndAssignable() const
Determine whether this lambda should have an implicit default constructor and copy and move assignmen...
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine whether this particular class is a specialization or instantiation of a class template or m...
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11,...
base_class_range vbases()
base_class_iterator vbases_begin()
void setImplicitMoveConstructorIsDeleted()
Set that we attempted to declare an implicit move constructor, but overload resolution failed so we d...
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool hasVariantMembers() const
Determine whether this class has any variant members.
void setImplicitCopyConstructorIsDeleted()
Set that we attempted to declare an implicit copy constructor, but overload resolution failed so we d...
bool isDynamicClass() const
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
bool hasNonTrivialCopyConstructorForCall() const
bool hasDirectFields() const
Determine whether this class has direct non-static data members.
bool hasUserDeclaredCopyConstructor() const
Determine whether this class has a user-declared copy constructor.
bool hasDefinition() const
void setImplicitCopyAssignmentIsDeleted()
Set that we attempted to declare an implicit copy assignment operator, but overload resolution failed...
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
void getFinalOverriders(CXXFinalOverriderMap &FinaOverriders) const
Retrieve the final overriders for each virtual member function in the class hierarchy where this clas...
bool needsOverloadResolutionForMoveConstructor() const
Determine whether we need to eagerly declare a defaulted move constructor for this class.
bool needsOverloadResolutionForMoveAssignment() const
Determine whether we need to eagerly declare a move assignment operator for this class.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
bool hasNonTrivialDestructorForCall() const
bool needsOverloadResolutionForDestructor() const
Determine whether we need to eagerly declare a destructor for this class.
bool hasInheritedConstructor() const
Determine whether this class has a using-declaration that names a user-declared base class constructo...
CXXMethodDecl * getLambdaStaticInvoker() const
Retrieve the lambda static invoker, the address of which is returned by the conversion operator,...
bool needsOverloadResolutionForCopyConstructor() const
Determine whether we need to eagerly declare a defaulted copy constructor for this class.
bool hasUserDeclaredMoveConstructor() const
Determine whether this class has had a move constructor declared by the user.
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
bool isInterfaceLike() const
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared.
bool hasTrivialMoveConstructorForCall() const
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
unsigned getNumVBases() const
Retrieves the number of virtual base classes of this class.
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
bool implicitCopyAssignmentHasConstParam() const
Determine whether an implicit copy assignment operator for this type would have a parameter with a co...
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isEmpty() const
No scope specifier.
Represents the this expression in C++.
SourceLocation getBeginLoc() const
SourceLocation getLocation() const
CXXTryStmt - A C++ try block, including all handlers.
CXXCatchStmt * getHandler(unsigned i)
unsigned getNumHandlers() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isCallToStdMove() const
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
CanProxy< U > getAs() const
Retrieve a canonical type pointer with a different static type, upcasting or downcasting as needed.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CastKind getCastKind() const
static CharSourceRange getTokenRange(SourceRange R)
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
ClassTemplateDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
Represents a class template specialization, which refers to a class template with a given set of temp...
TemplateSpecializationKind getSpecializationKind() const
Determine the kind of specialization that this declaration represents.
ClassTemplateDecl * getSpecializedTemplate() const
Retrieve the template that this specialization specializes.
SourceLocation getPointOfInstantiation() const
Get the point of instantiation (if any), or null if none.
bool isExplicitSpecialization() const
const ComparisonCategoryInfo * lookupInfoForType(QualType Ty) const
const ComparisonCategoryInfo & getInfoForType(QualType Ty) const
Return the comparison category information as specified by getCategoryForType(Ty).
const ComparisonCategoryInfo * lookupInfo(ComparisonCategoryType Kind) const
Return the cached comparison category information for the specified 'Kind'.
static StringRef getCategoryString(ComparisonCategoryType Kind)
static StringRef getResultString(ComparisonCategoryResult Kind)
static std::vector< ComparisonCategoryResult > getPossibleResultsForType(ComparisonCategoryType Type)
Return the list of results which are valid for the specified comparison category type.
const CXXRecordDecl * Record
The declaration for the comparison category type from the standard library.
const ValueInfo * getValueInfo(ComparisonCategoryResult ValueKind) const
ComparisonCategoryType Kind
The Kind of the comparison category type.
Complex values, per C99 6.2.5p11.
QualType getElementType() const
CompoundStmt - This represents a group of statements like { stmt stmt }.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
ConditionalOperator - The ?: ternary operator.
ConstStmtVisitor - This class implements a simple visitor for Stmt subclasses.
Represents the canonical version of C arrays with a specified constant size.
const llvm::APInt & getSize() const
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
Represents a shadow constructor declaration introduced into a class by a C++11 using-declaration that...
const CXXRecordDecl * getParent() const
Returns the parent of this using shadow declaration, which is the class in which this is declared.
static ConstructorUsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, UsingDecl *Using, NamedDecl *Target, bool IsVirtual)
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
A POD class for pairing a NamedDecl* with an access specifier.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
NamedDecl * getDecl() const
AccessSpecifier getAccess() const
The results of name lookup within a DeclContext.
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext,...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC.
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
bool isTranslationUnit() const
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
void removeDecl(Decl *D)
Removes a declaration from this context.
void addDecl(Decl *D)
Add the declaration D into this context.
decl_iterator decls_end() const
RecordDecl * getOuterLexicalRecordContext()
Retrieve the outermost lexically enclosing record context.
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isFunctionOrMethod() const
const LinkageSpecDecl * getExternCContext() const
Retrieve the nearest enclosing C linkage specification context.
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
decl_iterator decls_begin() const
A reference to a declared variable, function, enum, etc.
SourceLocation getBeginLoc() const LLVM_READONLY
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
NonOdrUseReason isNonOdrUse() const
Is this expression a non-odr-use reference, and if so, why?
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool isModulePrivateSpecified() const
static const TST TST_typename
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
SourceLocation getExplicitSpecLoc() const
SourceLocation getFriendSpecLoc() const
TSCS getThreadStorageClassSpec() const
ParsedAttributes & getAttributes()
SourceLocation getConstSpecLoc() const
SourceRange getExplicitSpecRange() const
Expr * getRepAsExpr() const
static const TST TST_enum
SourceLocation getTypeSpecTypeNameLoc() const
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
bool SetTypeQual(TQ T, SourceLocation Loc)
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getThreadStorageClassSpecLoc() const
Decl * getRepAsDecl() const
bool isFriendSpecified() const
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
SourceLocation getTypeSpecTypeLoc() const
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
SourceLocation getVolatileSpecLoc() const
bool hasExplicitSpecifier() const
bool hasConstexprSpecifier() const
static const TST TST_auto
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
SourceLocation getBeginLoc() const LLVM_READONLY
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
SourceLocation getEndLoc() const LLVM_READONLY
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so,...
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Kind
Lists the kind of concrete classes of Decl.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
@ FOK_Undeclared
A friend of a previously-undeclared entity.
@ FOK_None
Not a friend object.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
bool isInvalidDecl() const
unsigned getIdentifierNamespace() const
void setAccess(AccessSpecifier AS)
SourceLocation getLocation() const
@ IDNS_Ordinary
Ordinary names.
bool isTemplateParameterPack() const
isTemplateParameter - Determines whether this declaration is a template parameter pack.
void setLocalOwningModule(Module *M)
void setImplicit(bool I=true)
void setReferenced(bool R=true)
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
SourceLocation getBeginLoc() const LLVM_READONLY
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
void setModuleOwnershipKind(ModuleOwnershipKind MOK)
Set whether this declaration is hidden from name lookup.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
std::string getAsString() const
Retrieve the human-readable string for this name.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
NameKind getNameKind() const
Determine what kind of name this is.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Represents a ValueDecl that came out of a declarator.
SourceLocation getBeginLoc() const LLVM_READONLY
unsigned getNumTemplateParameterLists() const
void setTypeSourceInfo(TypeSourceInfo *TI)
Expr * getTrailingRequiresClause()
Get the constraint-expression introduced by the trailing requires-clause in the function/member decla...
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
bool isFunctionDeclarationContext() const
Return true if this declaration appears in a context where a function declarator would be a function ...
SourceLocation getIdentifierLoc() const
type_object_range type_objects() const
Returns the range of type objects, from the identifier outwards.
bool hasGroupingParens() const
void setInvalidType(bool Val=true)
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isRedeclaration() const
DeclaratorContext getContext() const
const DecompositionDeclarator & getDecompositionDeclarator() const
SourceLocation getBeginLoc() const LLVM_READONLY
bool isFunctionDefinition() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
void setInventedTemplateParameterList(TemplateParameterList *Invented)
Sets the template parameter list generated from the explicit template parameters along with any inven...
IdentifierInfo * getIdentifier() const
bool mayHaveDecompositionDeclarator() const
Return true if the context permits a C++17 decomposition declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isDecompositionDeclarator() const
Return whether this declarator is a decomposition declarator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A decomposition declaration.
ArrayRef< BindingDecl * > bindings() const
A parsed C++17 decomposition declarator of the form '[' identifier-list ']'.
ArrayRef< Binding > bindings() const
SourceRange getSourceRange() const
SourceLocation getLSquareLoc() const
Represents a C++17 deduced template specialization type.
void setNameLoc(SourceLocation Loc)
void setElaboratedKeywordLoc(SourceLocation Loc)
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setElaboratedKeywordLoc(SourceLocation Loc)
TypeLoc getNamedTypeLoc() const
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static EmptyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
RAII object that enters a new expression evaluation context.
An instance of this object exists for each enum constant that is defined.
enumerator_range enumerators() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums.
EvaluatedExprVisitor - This class visits 'Expr *'s.
Store information needed for an explicit specifier.
const Expr * getExpr() const
void setKind(ExplicitSpecKind Kind)
This represents one expression.
static bool isPotentialConstantExpr(const FunctionDecl *FD, SmallVectorImpl< PartialDiagnosticAt > &Diags)
isPotentialConstantExpr - Return true if this function's definition might be usable in a constant exp...
bool isValueDependent() const
Determines whether the value of this expression depends on.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language.
bool isTemporaryObject(ASTContext &Ctx, const CXXRecordDecl *TempTy) const
Determine whether the result of this expression is a temporary object of the given class type.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
void setInClassInitializer(Expr *Init)
Set the C++11 in-class initializer for this member.
bool hasInClassInitializer() const
Determine whether this member has a C++11 default member initializer.
unsigned getFieldIndex() const
Returns the index of this field within its record, as appropriate for passing to ASTRecordLayout::get...
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
InClassInitStyle getInClassInitStyle() const
Get the kind of (C++11) default member initializer that this field has.
void removeInClassInitializer()
Remove the C++11 in-class initializer from this member.
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set.
const RecordDecl * getParent() const
Returns the parent of this field declaration, which is the struct in which this field is defined.
FieldDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this field.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
void setUnsupportedFriend(bool Unsupported)
static FriendDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, FriendUnion Friend_, SourceLocation FriendL, ArrayRef< TemplateParameterList * > FriendTypeTPLists=None)
static FriendTemplateDecl * Create(ASTContext &Context, DeclContext *DC, SourceLocation Loc, MutableArrayRef< TemplateParameterList * > Params, FriendUnion Friend, SourceLocation FriendLoc)
static DefaultedFunctionInfo * Create(ASTContext &Context, ArrayRef< DeclAccessPair > Lookups)
Represents a function declaration or definition.
const ParmVarDecl * getParamDecl(unsigned i) const
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
ExceptionSpecificationType getExceptionSpecType() const
Gets the ExceptionSpecificationType as declared.
bool isTrivialForCall() const
bool isPure() const
Whether this virtual function is pure, i.e.
ConstexprSpecKind getConstexprKind() const
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to call this function.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type.
bool isDestroyingOperatorDelete() const
Determine whether this is a destroying operator delete.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
QualType getReturnType() const
ArrayRef< ParmVarDecl * > parameters() const
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
MutableArrayRef< ParmVarDecl * >::iterator param_iterator
void setWillHaveBody(bool V=true)
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
param_iterator param_begin()
bool isVariadic() const
Whether this function is variadic.
bool doesThisDeclarationHaveABody() const
Returns whether this specific declaration of the function has a body.
bool isDeleted() const
Whether this function has been deleted.
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
StorageClass getStorageClass() const
Returns the storage class as written in the source.
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program.
void setImplicitlyInline(bool I=true)
Flag that this function is implicitly inline.
void setTrivialForCall(bool IT)
bool isThisDeclarationInstantiatedFromAFriendDefinition() const
Determine whether this specific declaration of the function is a friend declaration that was instanti...
bool isDefaulted() const
Whether this function is defaulted.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
void setConstexprKind(ConstexprSpecKind CSK)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
void setDefaulted(bool D=true)
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
QualType getDeclaredReturnType() const
Get the declared return type, which may differ from the actual return type if the return type is dedu...
DefaultedFunctionInfo * getDefaultedFunctionInfo() const
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
bool hasOneParamOrDefaultArgs() const
Determine whether this function has a single parameter, or multiple parameters where all but the firs...
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
size_t param_size() const
void setDeletedAsWritten(bool D=true)
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
void setDefaultedFunctionInfo(DefaultedFunctionInfo *Info)
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
void setParams(ArrayRef< ParmVarDecl * > NewParamInfo)
bool willHaveBody() const
True if this function will eventually have a body, once it's fully parsed.
Represents a prototype with parameter type info, e.g.
ExtParameterInfo getExtParameterInfo(unsigned I) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
unsigned getNumParams() const
bool hasTrailingReturn() const
Whether this function prototype has a trailing return type.
QualType getParamType(unsigned i) const
bool isVariadic() const
Whether this function prototype is variadic.
ExtProtoInfo getExtProtoInfo() const
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
ArrayRef< QualType > getParamTypes() const
ArrayRef< QualType > exceptions() const
bool hasExtParameterInfos() const
Is there any interesting extra information for any of the parameters of this function type?
Declaration of a template function.
Wrapper for source info for functions.
unsigned getNumParams() const
ParmVarDecl * getParam(unsigned i) const
void setParam(unsigned i, ParmVarDecl *VD)
TypeLoc getReturnLoc() const
ExtInfo withCallingConv(CallingConv cc) const
FunctionType - C99 6.7.5.3 - Function Declarators.
CallingConv getCallConv() const
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
unsigned getLength() const
Efficiently return the length of this identifier info.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
IfStmt - This represents an if/then/else.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents an implicitly-generated value initialization of an object of a given type.
Represents a field injected from an anonymous union/struct into the parent scope.
ArrayRef< NamedDecl * > chain() const
void setInherited(bool I)
Description of a constructor that was inherited from a base class.
ConstructorUsingShadowDecl * getShadowDecl() const
const TypeClass * getTypePtr() const
Describes an C or C++ initializer list.
unsigned getNumInits() const
const Expr * getInit(unsigned Init) const
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Describes an entity that is being initialized.
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
An lvalue reference type, per C++11 [dcl.ref].
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
SourceLocation getBeginLoc() const LLVM_READONLY
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
Represents a linkage specification.
void setRBraceLoc(SourceLocation L)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
LanguageIDs
Represents the language in a linkage specification.
A class for iterating through a result set and possibly filtering out results.
void erase()
Erase the last element returned from this iterator.
Represents the results of name lookup.
@ FoundOverloaded
Name lookup found a set of overloaded functions that met the criteria.
@ FoundUnresolvedValue
Name lookup found an unresolvable value declaration and cannot yet complete.
@ Ambiguous
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
@ NotFound
No entity found met the criteria.
@ NotFoundInCurrentInstantiation
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
@ Found
Name lookup found a single declaration that met the criteria.
LLVM_ATTRIBUTE_REINITIALIZES void clear()
Clears out any current state.
void setBaseObjectType(QualType T)
Sets the base object type for this lookup.
DeclClass * getAsSingle() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool empty() const
Return true if no decls were found.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Filter makeFilter()
Create a filter for this result set.
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
An instance of this class represents the declaration of a property member.
static MSPropertyDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName N, QualType T, TypeSourceInfo *TInfo, SourceLocation StartL, IdentifierInfo *Getter, IdentifierInfo *Setter)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
SourceLocation getExprLoc() const LLVM_READONLY
Wrapper for source info for member pointers.
A pointer to member type per C++ 8.3.3 - Pointers to members.
Describes a module or submodule.
This represents a decl that may have a name.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Represents a C++ namespace alias.
static NamespaceAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Namespace)
Represent a C++ namespace.
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl)
bool isInline() const
Returns true if this is an inline namespace declaration.
NamespaceDecl * getAnonymousNamespace() const
Retrieve the anonymous namespace nested inside this namespace, if any.
void setRBraceLoc(SourceLocation L)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
A C++ nested-name-specifier augmented with source location information.
SourceRange getSourceRange() const LLVM_READONLY
Retrieve the source range covering the entirety of this nested-name-specifier.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
@ Global
The global specifier '::'. There is no stored value.
bool containsUnexpandedParameterPack() const
Whether this nested-name-specifier contains an unexpanded parameter pack (for C++11 variadic template...
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
Represents an ObjC class declaration.
The basic abstraction for the target Objective-C runtime.
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
@ CSK_Operator
C++ [over.match.oper]: Lookup of operator function candidates in a call using operator syntax.
SmallVectorImpl< OverloadCandidate >::iterator iterator
MapType::iterator iterator
MapType::const_iterator const_iterator
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
static ParenListExpr * Create(const ASTContext &Ctx, SourceLocation LParenLoc, ArrayRef< Expr * > Exprs, SourceLocation RParenLoc)
Create a paren list.
Represents a parameter to a function.
void setDefaultArg(Expr *defarg)
void setUnparsedDefaultArg()
Specify that this parameter has an unparsed default argument.
bool hasUnparsedDefaultArg() const
Determines whether this parameter has a default argument that has not yet been parsed.
SourceRange getDefaultArgRange() const
Retrieve the source range that covers the entire default argument.
void setUninstantiatedDefaultArg(Expr *arg)
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
bool hasUninstantiatedDefaultArg() const
bool hasInheritedDefaultArg() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Expr * getUninstantiatedDefaultArg()
bool hasDefaultArg() const
Determines whether this parameter has a default argument, either parsed or not.
void setHasInheritedDefaultArg(bool I=true)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
ParsedAttr - Represents a syntactic attribute.
IdentifierInfo * getPropertyDataSetter() const
bool isDeclspecPropertyAttribute() const
Is this the Microsoft __declspec(property) attribute?
IdentifierInfo * getPropertyDataGetter() const
static const ParsedAttributesView & none()
bool hasAttribute(ParsedAttr::Kind K) const
Wrapper for source info for pointers.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
IdentifierTable & getIdentifierTable()
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
llvm::iterator_range< semantics_iterator > semantics()
A (possibly-)qualified type.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
QualType withConst() const
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
unsigned getLocalCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers local to this particular QualType instan...
bool isMoreQualifiedThan(QualType Other) const
Determine whether this type is more qualified than the other given type, requiring exact equality for...
bool isConstQualified() const
Determine whether this type is const-qualified.
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
bool hasNonTrivialObjCLifetime() const
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
The collection of all-type qualifiers we support.
void addAddressSpace(LangAS space)
@ OCL_Weak
Reading or writing from this object requires a barrier call.
void removeAddressSpace()
LangAS getAddressSpace() const
An rvalue reference type, per C++11 [dcl.ref].
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
field_iterator field_end() const
field_range fields() const
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
@ APK_CanNeverPassInRegs
The argument of this type cannot be passed directly in registers.
@ APK_CanPassInRegs
The argument of this type can be passed directly in registers.
@ APK_CannotPassInRegs
The argument of this type cannot be passed directly in registers.
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
bool isAnonymousStructOrUnion() const
Whether this is an anonymous struct or union.
field_iterator field_begin() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
RecordDecl * getDecl() const
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Base for LValueReferenceType and RValueReferenceType.
QualType getPointeeType() const
ReturnStmt - This represents a return, optionally of an expression: return; return 4;.
Scope - A scope is a transient data structure that is used while parsing the program.
void setEntity(DeclContext *E)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ DeclScope
This is a scope that can contain a declaration.
A RAII object to enter scope of a compound statement.
For a defaulted function, the kind of defaulted function that it is.
DefaultedComparisonKind asComparison() const
bool isSpecialMember() const
CXXSpecialMember asSpecialMember() const
bool isComparison() const
Helper class that collects exception specifications for implicitly-declared special member functions.
void CalledStmt(Stmt *S)
Integrate an invoked statement into the collected data.
void CalledExpr(Expr *E)
Integrate an invoked expression into the collected data.
void CalledDecl(SourceLocation CallLoc, const CXXMethodDecl *Method)
Integrate another called method into the collected data.
A generic diagnostic builder for errors which may or may not be deferred.
SpecialMemberOverloadResult - The overloading result for a special member function.
CXXMethodDecl * getMethod() const
RAII object to handle the state changes required to synthesize a function body.
Abstract base class used for diagnosing integer constant expression violations.
Sema - This implements semantic analysis and AST building for C.
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S)
MergeCXXFunctionDecl - Merge two declarations of the same C++ function, once we already know that the...
MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, Expr *Init, CXXRecordDecl *ClassDecl)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, const CXXMethodDecl *Old)
void DiagnoseAbstractType(const CXXRecordDecl *RD)
void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow)
Hides a using shadow declaration.
bool CheckUsingDeclQualifier(SourceLocation UsingLoc, bool HasTypename, const CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, SourceLocation NameLoc, const LookupResult *R=nullptr, const UsingDecl *UD=nullptr)
Checks that the given nested-name qualifier used in a using decl in the current context is appropriat...
llvm::SmallPtrSet< SpecialMemberDecl, 4 > SpecialMembersBeingDeclared
The C++ special members which we are currently in the process of declaring.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
DefaultedFunctionKind getDefaultedFunctionKind(const FunctionDecl *FD)
Determine the kind of defaulting that would be done for a given function.
ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, SourceLocation OpLoc, bool IsArrow, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs, const Scope *S, ActOnMemberAccessExtraArgs *ExtraArgs=nullptr)
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath)
void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old)
Merge the exception specifications of two variable declarations.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
void EvaluateImplicitExceptionSpec(SourceLocation Loc, FunctionDecl *FD)
Evaluate the implicit exception specification for a defaulted special member function.
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
void ActOnFinishCXXNonNestedClass()
MemInitResult BuildBaseInitializer(QualType BaseType, TypeSourceInfo *BaseTInfo, Expr *Init, CXXRecordDecl *ClassDecl, SourceLocation EllipsisLoc)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
void ActOnFinishDelayedMemberInitializers(Decl *Record)
void CheckDelegatingCtorCycles()
void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, CXXRecordDecl *Record)
MarkBaseAndMemberDestructorsReferenced - Given a record decl, mark all the non-trivial destructors of...
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void LookupOverloadedBinOp(OverloadCandidateSet &CandidateSet, OverloadedOperatorKind Op, const UnresolvedSetImpl &Fns, ArrayRef< Expr * > Args, bool RequiresADL=true)
Perform lookup for an overloaded binary operator.
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
bool isImplicitlyDeleted(FunctionDecl *FD)
Determine whether the given function is an implicitly-deleted special member function.
void CheckImplicitSpecialMemberDeclaration(Scope *S, FunctionDecl *FD)
Check a completed declaration of an implicit special member.
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, QualType DeclInitType, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
void CheckOverrideControl(NamedDecl *D)
CheckOverrideControl - Check C++11 override control semantics.
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
void referenceDLLExportedClassMethods()
void CheckCompleteDestructorVariant(SourceLocation CurrentLocation, CXXDestructorDecl *Dtor)
Do semantic checks to allow the complete destructor variant to be emitted when the destructor is defi...
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckForFunctionMarkedFinal - Checks whether a virtual member function overrides a virtual member fun...
NamedDecl * BuildUsingEnumDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation NameLoc, EnumDecl *ED)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, AllowFoldKind CanFold=NoFold)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl)
AddImplicitlyDeclaredMembersToClass - Adds any implicitly-declared special functions,...
bool tryResolveExplicitSpecifier(ExplicitSpecifier &ExplicitSpec)
tryResolveExplicitSpecifier - Attempt to resolve the explict specifier.
Decl * ActOnConversionDeclarator(CXXConversionDecl *Conversion)
ActOnConversionDeclarator - Called by ActOnDeclarator to complete the declaration of the given C++ co...
QualType BuildStdInitializerList(QualType Element, SourceLocation Loc)
Looks for the std::initializer_list template and instantiates it with Element, or emits an error if i...
MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr *Init, SourceLocation IdLoc)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
FPOptionsOverride CurFPFeatureOverrides()
void DiagnoseHiddenVirtualMethods(CXXMethodDecl *MD)
Diagnose methods which overload virtual methods in a base class without overriding any.
UsingShadowDecl * BuildUsingShadowDecl(Scope *S, BaseUsingDecl *BUD, NamedDecl *Target, UsingShadowDecl *PrevDecl)
Builds a shadow declaration corresponding to a 'using' declaration.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallToMemberFunction - Build a call to a member function.
bool isMemberAccessibleForDeletion(CXXRecordDecl *NamingClass, DeclAccessPair Found, QualType ObjectType, SourceLocation Loc, const PartialDiagnostic &Diag)
Is the given member accessible for the purposes of deciding whether to define a special member functi...
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
Decl * BuildStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *AssertMessageExpr, SourceLocation RParenLoc, bool Failed)
bool DeduceReturnType(FunctionDecl *FD, SourceLocation Loc, bool Diagnose=true)
void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnFinishDelayedCXXMethodDeclaration - We have finished processing the delayed method declaration f...
DiagnosticsEngine & getDiagnostics() const
ExprResult ActOnCXXThis(SourceLocation loc)
void propagateDLLAttrToBaseClassTemplate(CXXRecordDecl *Class, Attr *ClassAttr, ClassTemplateSpecializationDecl *BaseTemplateSpec, SourceLocation BaseLoc)
Perform propagation of DLL attributes from a derived class to a templated base class for MS compatibi...
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
void CheckDelayedMemberExceptionSpecs()
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, UnresolvedSetImpl &Functions)
ASTContext & getASTContext() const
void CheckExplicitlyDefaultedFunction(Scope *S, FunctionDecl *MD)
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
void checkExceptionSpecification(bool IsTopLevel, ExceptionSpecificationType EST, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr, SmallVectorImpl< QualType > &Exceptions, FunctionProtoType::ExceptionSpecInfo &ESI)
Check the given exception-specification and update the exception specification information with the r...
bool checkThisInStaticMemberFunctionType(CXXMethodDecl *Method)
Check whether 'this' shows up in the type of a static member function after the (naturally empty) cv-...
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS, bool RequiresADL=true, bool AllowRewrittenCandidates=true, FunctionDecl *DefaultedFn=nullptr)
Create a binary operation that may resolve to an overloaded operator.
bool isInitListConstructor(const FunctionDecl *Ctor)
Determine whether Ctor is an initializer-list constructor, as defined in [dcl.init....
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
DefaultedComparisonKind
Kinds of defaulted comparison operator functions.
bool RequireLiteralType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a literal type.
void ActOnStartCXXInClassMemberInitializer()
Enter a new C++ default initializer scope.
NamedDecl * BuildUsingDeclaration(Scope *S, AccessSpecifier AS, SourceLocation UsingLoc, bool HasTypenameKeyword, SourceLocation TypenameLoc, CXXScopeSpec &SS, DeclarationNameInfo NameInfo, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList, bool IsInstantiation, bool IsUsingIfExists)
Builds a using declaration.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
DeclRefExpr * BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
EnumDecl * getStdAlignValT() const
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs, const DeclSpec *DS=nullptr)
void CheckDeductionGuideDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Check the validity of a declarator that we parsed for a deduction-guide.
void SetDeclDefaulted(Decl *dcl, SourceLocation DefaultLoc)
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
const LangOptions & getLangOpts() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
QualType CheckComparisonCategoryType(ComparisonCategoryType Kind, SourceLocation Loc, ComparisonCategoryUsage Usage)
Lookup the specified comparison category types in the standard library, an check the VarDecls possibl...
SpecialMemberOverloadResult LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
void DiagnoseAbsenceOfOverrideControl(NamedDecl *D, bool Inconsistent)
DiagnoseAbsenceOfOverrideControl - Diagnose if 'override' keyword was not used in the declaration of ...
AccessResult CheckStructuredBindingMemberAccess(SourceLocation UseLoc, CXXRecordDecl *DecomposedClass, DeclAccessPair Field)
Checks implicit access to a member in a structured binding.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
void DefineDefaultedComparison(SourceLocation Loc, FunctionDecl *FD, DefaultedComparisonKind DCK)
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, NamedDecl *FoundDecl, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
bool SpecialMemberIsTrivial(CXXMethodDecl *MD, CXXSpecialMember CSM, TrivialABIHandling TAH=TAH_IgnoreTrivialABI, bool Diagnose=false)
Determine whether a defaulted or deleted special member function is trivial, as specified in C++11 [c...
bool CheckConstexprFunctionDefinition(const FunctionDecl *FD, CheckConstexprKind Kind)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false, bool AllowRecovery=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, QualType Base, QualType Derived, const CXXBasePath &Path, unsigned DiagID, bool ForceCheck=false, bool ForceUnprivileged=false)
Checks access for a hierarchy conversion.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator,...
void CheckCompleteDecompositionDeclaration(DecompositionDecl *DD)
void checkClassLevelDLLAttribute(CXXRecordDecl *Class)
Check class-level dllimport/dllexport attribute.
const LangOptions & LangOpts
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock)
void MarkVirtualMembersReferenced(SourceLocation Loc, const CXXRecordDecl *RD, bool ConstexprOnly=false)
MarkVirtualMembersReferenced - Will mark all members of the given CXXRecordDecl referenced.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
CXXRecordDecl * getStdBadAlloc() const
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange)
Mark the given method pure.
void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
void NoteHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
void DiagnoseNontrivial(const CXXRecordDecl *Record, CXXSpecialMember CSM)
Diagnose why the specified class does not have a trivial special member of the given kind.
void CheckCXXDefaultArguments(FunctionDecl *FD)
CheckCXXDefaultArguments - Verify that the default arguments for a function declaration are well-form...
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
NamespaceDecl * lookupStdExperimentalNamespace()
void MarkVirtualMemberExceptionSpecsNeeded(SourceLocation Loc, const CXXRecordDecl *RD)
Mark the exception specifications of all virtual member functions in the given class as needed.
bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl)
CheckOverloadedOperatorDeclaration - Check whether the declaration of this overloaded operator is wel...
void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir)
void CheckConstructor(CXXConstructorDecl *Constructor)
CheckConstructor - Checks a fully-formed constructor for well-formedness, issuing any diagnostics req...
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
void popCodeSynthesisContext()
CXXRecordDecl * getCurrentClass(Scope *S, const CXXScopeSpec *SS)
Get the class that is directly named by the current context.
void pushCodeSynthesisContext(CodeSynthesisContext Ctx)
QualType BuildReferenceType(QualType T, bool LValueRef, SourceLocation Loc, DeclarationName Entity)
Build a reference type.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
bool checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method)
Check whether 'this' shows up in the attributes of the given static member function.
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
CXXBaseSpecifier * CheckBaseSpecifier(CXXRecordDecl *Class, SourceRange SpecifierRange, bool Virtual, AccessSpecifier Access, TypeSourceInfo *TInfo, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
VarDecl * BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Perform semantic analysis for the variable declaration that occurs within a C++ catch clause,...
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
ExprResult DefaultLvalueConversion(Expr *E)
bool CheckUsingShadowDecl(BaseUsingDecl *BUD, NamedDecl *Target, const LookupResult &PreviousDecls, UsingShadowDecl *&PrevShadow)
Determines whether to create a using shadow decl for a particular decl, given the set of decls existi...
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
llvm::PointerIntPair< CXXRecordDecl *, 3, CXXSpecialMember > SpecialMemberDecl
FriendDecl * CheckFriendTypeDecl(SourceLocation LocStart, SourceLocation FriendLoc, TypeSourceInfo *TSInfo)
Perform semantic analysis of the given friend type declaration.
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl, bool ConsiderCudaAttrs=true, bool ConsiderRequiresClauses=true)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, CXXCtorInitializer *Initializer)
@ TAH_IgnoreTrivialABI
The triviality of a method unaffected by "trivial_abi".
@ TAH_ConsiderTrivialABI
The triviality of a method affected by "trivial_abi".
bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl)
CheckLiteralOperatorDeclaration - Check whether the declaration of this literal operator function is ...
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
void MarkVirtualBaseDestructorsReferenced(SourceLocation Location, CXXRecordDecl *ClassDecl, llvm::SmallPtrSetImpl< const RecordType * > *DirectVirtualBases=nullptr)
Mark destructors of virtual bases of this class referenced.
void checkIllFormedTrivialABIStruct(CXXRecordDecl &RD)
Check that the C++ class annoated with "trivial_abi" satisfies all the conditions that are needed for...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
StmtResult ActOnForStmt(SourceLocation ForLoc, SourceLocation LParenLoc, Stmt *First, ConditionResult Second, FullExprArg Third, SourceLocation RParenLoc, Stmt *Body)
unsigned ActOnReenterTemplateScope(Decl *Template, llvm::function_ref< Scope *()> EnterScope)
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
NamedDecl * ActOnDecompositionDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists)
Decl * ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, MultiTemplateParamsArg TemplateParams)
Handle a friend type declaration.
std::pair< CXXRecordDecl *, SourceLocation > VTableUse
The list of classes whose vtables have been used within this translation unit, and the source locatio...
ExprResult BuildFieldReferenceExpr(Expr *BaseExpr, bool IsArrow, SourceLocation OpLoc, const CXXScopeSpec &SS, FieldDecl *Field, DeclAccessPair FoundDecl, const DeclarationNameInfo &MemberNameInfo)
bool CheckExplicitlyDefaultedComparison(Scope *S, FunctionDecl *MD, DefaultedComparisonKind DCK)
bool checkThisInStaticMemberFunctionExceptionSpec(CXXMethodDecl *Method)
Whether this' shows up in the exception specification of a static member function.
llvm::FoldingSet< SpecialMemberOverloadResultEntry > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void FilterUsingLookup(Scope *S, LookupResult &lookup)
Remove decls we can't actually see from a lookup being used to declare shadow using decls.
void actOnDelayedExceptionSpecification(Decl *Method, ExceptionSpecificationType EST, SourceRange SpecificationRange, ArrayRef< ParsedType > DynamicExceptions, ArrayRef< SourceRange > DynamicExceptionRanges, Expr *NoexceptExpr)
Add an exception-specification to the given member function (or member function template).
Decl * ActOnExceptionDeclarator(Scope *S, Declarator &D)
ActOnExceptionDeclarator - Parsed the exception-declarator in a C++ catch handler.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void ActOnFinishCXXInClassMemberInitializer(Decl *VarDecl, SourceLocation EqualLoc, Expr *Init)
This is invoked after parsing an in-class initializer for a non-static C++ class member,...
QualType CheckTemplateIdType(TemplateName Template, SourceLocation TemplateLoc, TemplateArgumentListInfo &TemplateArgs)
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, const DeclSpec &)
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void AdjustDestructorExceptionSpec(CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
StmtResult BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp, bool AllowRecovery=false)
bool isCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind=CompleteTypeKind::Default)
void InstantiateDefaultCtorDefaultArgs(CXXConstructorDecl *Ctor)
In the MS ABI, we need to instantiate default arguments of dllexported default constructors along wit...
void CheckCompleteVariableDeclaration(VarDecl *VD)
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
void checkClassLevelCodeSegAttribute(CXXRecordDecl *Class)
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL,...
void SetFunctionBodyKind(Decl *D, SourceLocation Loc, FnBodyKind BodyKind)
bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, bool HasTypenameKeyword, const CXXScopeSpec &SS, SourceLocation NameLoc, const LookupResult &Previous)
Checks that the given using declaration is not an invalid redeclaration.
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
bool ShouldDeleteSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM, InheritedConstructorInfo *ICI=nullptr, bool Diagnose=false)
Determine if a special member function should have a deleted definition when it is defaulted.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
bool CheckInheritingConstructorUsingDecl(UsingDecl *UD)
Additional checks for a using declaration referring to a constructor name.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
MemInitResult BuildMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, Expr *Init, SourceLocation EllipsisLoc)
Handle a C++ member initializer.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
void NoteDeletedInheritingConstructor(CXXConstructorDecl *CD)
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
void checkInitializerLifetime(const InitializedEntity &Entity, Expr *Init)
Check that the lifetime of the initializer (and its subobjects) is sufficient for initializing the en...
void CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record)
Perform semantic checks on a class definition that has been completing, introducing implicitly-declar...
void DiscardCleanupsInEvaluationContext()
bool CheckDestructor(CXXDestructorDecl *Destructor)
CheckDestructor - Checks a fully-formed destructor definition for well-formedness,...
NamedDecl * BuildUsingPackDecl(NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > Expansions)
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method)
ActOnStartDelayedCXXMethodDeclaration - We have completed parsing a top-level (non-nested) C++ class,...
DiagnosticsEngine & Diags
FullExprArg MakeFullDiscardedValueExpr(Expr *Arg)
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
NamespaceDecl * getStdNamespace() const
void DeclareImplicitEqualityComparison(CXXRecordDecl *RD, FunctionDecl *Spaceship)
bool AttachBaseSpecifiers(CXXRecordDecl *Class, MutableArrayRef< CXXBaseSpecifier * > Bases)
Performs the actual work of attaching the given base class specifiers to a C++ class.
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
ExprResult BuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Decl * ActOnEmptyDeclaration(Scope *S, const ParsedAttributesView &AttrList, SourceLocation SemiLoc)
Handle a C++11 empty-declaration and attribute-declaration.
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc)
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isUsualDeallocationFunction(const CXXMethodDecl *FD)
void DiagnoseDeletedDefaultedFunction(FunctionDecl *FD)
Produce notes explaining why a defaulted function was defined as deleted.
ExprResult BuildCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, TypeSourceInfo *Ty, Expr *E, SourceRange AngleBrackets, SourceRange Parens)
bool CheckExplicitlyDefaultedSpecialMember(CXXMethodDecl *MD, CXXSpecialMember CSM)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2,...
bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, const CXXMethodDecl *Old)
CheckOverridingFunctionReturnType - Checks whether the return types are covariant,...
StmtResult ActOnIfStmt(SourceLocation IfLoc, IfStatementKind StatementKind, SourceLocation LParenLoc, Stmt *InitStmt, ConditionResult Cond, SourceLocation RParenLoc, Stmt *ThenVal, SourceLocation ElseLoc, Stmt *ElseVal)
MSPropertyDecl * HandleMSProperty(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS, const ParsedAttr &MSPropertyAttr)
HandleMSProperty - Analyze a __delcspec(property) field of a C++ class.
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc.
void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc)
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
CXXSpecialMember
Kinds of C++ special members.
bool SetCtorInitializers(CXXConstructorDecl *Constructor, bool AnyErrors, ArrayRef< CXXCtorInitializer * > Initializers=None)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void LoadExternalVTableUses()
Load any externally-stored vtable uses.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, ArrayRef< Stmt * > Elts, bool isStmtExpr)
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
void FindHiddenVirtualMethods(CXXMethodDecl *MD, SmallVectorImpl< CXXMethodDecl * > &OverloadedMethods)
Check if a method overloads virtual methods in a base class without overriding any.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
CXXConstructorDecl * findInheritingConstructor(SourceLocation Loc, CXXConstructorDecl *BaseCtor, ConstructorUsingShadowDecl *DerivedShadow)
Given a derived-class using shadow declaration for a constructor and the correspnding base class cons...
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param)
ActOnDelayedCXXMethodParameter - We've already started a delayed C++ method declaration.
bool isAbstractType(SourceLocation Loc, QualType T)
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
ExprResult ActOnFinishFullExpr(Expr *Expr, bool DiscardedValue)
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
static StaticAssertDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StaticAssertLoc, Expr *AssertExpr, StringLiteral *Message, SourceLocation RParenLoc, bool Failed)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
static bool isValidUDSuffix(const LangOptions &LangOpts, StringRef Suffix)
Determine whether a suffix is a valid ud-suffix.
StringLiteral - This represents a string literal expression, e.g.
StringRef getString() const
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
StringRef getKindName() const
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
TagDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
TagKind getTagKind() const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
bool areArgsDestroyedLeftToRightInCallee() const
Are arguments to a call destroyed left to right in the callee? This is a fundamental language change,...
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
bool hasKeyFunctions() const
Does this ABI use key functions? If so, class data such as the vtable is emitted with strong linkage ...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
virtual bool shouldDLLImportComdatSymbols() const
Does this target aim for semantic compatibility with Microsoft C++ code using dllimport/export attrib...
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
TypeSourceInfo * getTypeSourceInfo() const
Represents a template argument.
@ Type
The template argument is a type.
ArgKind getKind() const
Return the kind of stored template argument.
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known.
@ Template
A single template declaration.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
SourceRange getSourceRange() const LLVM_READONLY
unsigned getDepth() const
Get the depth of this template parameter list in the set of template parameter lists.
unsigned getMinRequiredArguments() const
Returns the minimum number of arguments needed to form a template specialization.
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getRAngleLoc() const
SourceLocation getLAngleLoc() const
SourceLocation getTemplateLoc() const
unsigned getNumArgs() const
TemplateArgumentLoc getArgLoc(unsigned i) const
Represents a type template specialization; the template must be a class template, a type alias templa...
Declaration of a template type parameter.
unsigned getIndex() const
Retrieve the index of the template parameter.
unsigned getDepth() const
Retrieve the depth of the template parameter.
unsigned getIndex() const
unsigned getDepth() const
The top declaration context.
Represents the declaration of a typedef-name via a C++11 alias-declaration.
void setDescribedAliasTemplate(TypeAliasTemplateDecl *TAT)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
Declaration of an alias template.
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
Represents a declaration of a type.
const Type * getTypeForDecl() const
Base wrapper for a particular "section" of type source info.
QualType getType() const
Get the type for which this source info wrapper provides information.
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
TypeLoc IgnoreParens() const
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceRange getLocalSourceRange() const
Get the local source range.
TypeLocClass getTypeLocClass() const
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
A reasonable base class for TypeLocs that correspond to types that are written as a type-specifier.
static ElaboratedTypeKeyword getKeywordForTagTypeKind(TagTypeKind Tag)
Converts a TagTypeKind into an elaborated type keyword.
static StringRef getTagTypeKindName(TagTypeKind Kind)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isIncompleteArrayType() const
bool isUndeducedAutoType() const
bool isRValueReferenceType() const
CanQualType getCanonicalTypeUnqualified() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
bool isReferenceType() const
bool isEnumeralType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isLValueReferenceType() const
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
bool isFunctionProtoType() const
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
bool isFunctionType() const
bool isRealFloatingType() const
Floating point categories.
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
void WillReplaceSpecifier(bool ForceReplacement)
DeclClass * getCorrectionDeclAs() const
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static bool isIncrementDecrementOp(Opcode Op)
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a C++ unqualified-id that has been parsed.
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
SourceLocation getBeginLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
UnionParsedTemplateTy TemplateName
When Kind == IK_DeductionGuideName, the parsed template-name.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
static UnresolvedLookupExpr * Create(const ASTContext &Context, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool RequiresADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
A set of unresolved declarations.
ArrayRef< DeclAccessPair > pairs() const
The iterator over UnresolvedSets.
A set of unresolved declarations.
This node is generated when a using-declaration that was annotated with attribute((using_if_exists)) ...
static UnresolvedUsingIfExistsDecl * Create(ASTContext &Ctx, DeclContext *DC, SourceLocation Loc, DeclarationName Name)
Represents a dependent using declaration which was marked with typename.
static UnresolvedUsingTypenameDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation TypenameLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName, SourceLocation EllipsisLoc)
Represents a dependent using declaration which was not marked with typename.
static UnresolvedUsingValueDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, SourceLocation EllipsisLoc)
Represents a C++ using-declaration.
bool hasTypename() const
Return true if the using declaration has 'typename'.
DeclarationNameInfo getNameInfo() const
static UsingDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypenameKeyword)
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the name.
SourceLocation getUsingLoc() const
Return the source location of the 'using' keyword.
Represents C++ using-directive.
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Represents a C++ using-enum-declaration.
static UsingEnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingL, SourceLocation EnumL, SourceLocation NameL, EnumDecl *ED)
static UsingPackDecl * Create(ASTContext &C, DeclContext *DC, NamedDecl *InstantiatedFrom, ArrayRef< NamedDecl * > UsingDecls)
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
static UsingShadowDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, DeclarationName Name, BaseUsingDecl *Introducer, NamedDecl *Target)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
BaseUsingDecl * getIntroducer() const
Gets the (written or instantiated) using declaration that introduced this declaration.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool isNoDestroy(const ASTContext &) const
Is destruction of this variable entirely suppressed? If so, the variable need not have a usable destr...
bool isInlineSpecified() const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool evaluateDestruction(SmallVectorImpl< PartialDiagnosticAt > &Notes) const
Evaluate the destruction of this variable to determine if it constitutes constant destruction.
bool isStaticLocal() const
Returns true if a variable with function scope is a static local variable.
ThreadStorageClassSpecifier getTSCSpec() const
const Expr * getInit() const
@ TLS_Dynamic
TLS with a dynamic initializer.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isUsableInConstantExpressions(const ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
void setExceptionVariable(bool EV)
Declaration of a variable template.
Represents a GCC generic vector type.
unsigned getNumElements() const
QualType getElementType() const
Represents a C++11 virt-specifier-seq.
SourceLocation getOverrideLoc() const
SourceLocation getLastLocation() const
bool isOverrideSpecified() const
SourceLocation getFinalLoc() const
bool isFinalSpecified() const
bool isFinalSpelledSealed() const
Defines the clang::TargetInfo interface.
const AstTypeMatcher< RecordType > recordType
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
bool Zero(InterpState &S, CodePtr OpPC)
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
TypeSpecifierType
Specifies the kind of type.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
@ NUM_OVERLOADED_OPERATORS
bool isa(CodeGen::Address addr)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
@ OR_Deleted
Succeeded, but refers to a deleted function.
@ OR_Success
Overload resolution succeeded.
@ OR_Ambiguous
Ambiguous candidates found.
@ OR_No_Viable_Function
No viable function found.
@ Specialization
We are substituting template parameters for template arguments in order to form a template specializa...
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_ListInit
Direct list-initialization.
@ ICIS_NoInit
No in-class initializer.
@ RQ_None
No ref-qualifier was provided.
@ OCD_AmbiguousCandidates
Requests that only tied-for-best candidates be shown.
@ OCD_AllCandidates
Requests that all candidates be shown.
@ OK_Ordinary
An ordinary object is located at an address in memory.
StorageClass
Storage classes.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
ComparisonCategoryType commonComparisonType(ComparisonCategoryType A, ComparisonCategoryType B)
Determine the common comparison type, as defined in C++2a [class.spaceship]p4.
ComparisonCategoryResult
An enumeration representing the possible results of a three-way comparison.
MutableArrayRef< Expr * > MultiExprArg
Language
The language for the input, used to select and validate the language standard and possible actions.
@ C
Languages that the frontend can parse and compile.
ActionResult< ParsedType > TypeResult
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
TagTypeKind
The kind of a tag type.
@ TTK_Class
The "class" keyword.
@ TTK_Struct
The "struct" keyword.
@ TTK_Interface
The "__interface" keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
OverloadedOperatorKind getRewrittenOverloadedOperator(OverloadedOperatorKind Kind)
Get the other overloaded operator that the given operator can be rewritten into, if any such operator...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
@ TSK_ExplicitInstantiationDefinition
This template specialization was instantiated from a template due to an explicit instantiation defini...
@ TSK_ExplicitInstantiationDeclaration
This template specialization was instantiated from a template due to an explicit instantiation declar...
@ TSK_ExplicitSpecialization
This template specialization was declared or defined by an explicit specialization (C++ [temp....
@ TSK_ImplicitInstantiation
This template specialization was implicitly instantiated from a template.
@ TSK_Undeclared
This template specialization was formed from a template-id but has not yet been declared,...
CallingConv
CallingConv - Specifies the calling convention that a function uses.
U cast(CodeGen::Address addr)
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
@ ETK_None
No keyword precedes the qualified type name.
Optional< ComparisonCategoryType > getComparisonCategoryForBuiltinCmp(QualType T)
Get the comparison category that should be used when comparing values of type T.
bool isExternallyVisible(Linkage L)
ActionResult< Expr * > ExprResult
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_DependentNoexcept
noexcept(expression), value-dependent
@ EST_Uninstantiated
not instantiated yet
@ EST_Unparsed
not parsed yet
@ EST_NoThrow
Microsoft __declspec(nothrow) extension.
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_NoexceptFalse
noexcept(expression), evals to 'false'
@ EST_Unevaluated
not evaluated yet, for special member function
@ EST_NoexceptTrue
noexcept(expression), evals to 'true'
@ EST_Dynamic
throw(T1, T2)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
ActionResult< Stmt * > StmtResult
@ NOUR_Unevaluated
This name appears in an unevaluated operand.
bool hasValidIntValue() const
True iff we've successfully evaluated the variable as a constant expression and extracted its integer...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
SourceLocation getBeginLoc() const
getBeginLoc - Retrieve the location of the first token.
SourceRange getSourceRange() const LLVM_READONLY
getSourceRange - The range of the declaration name.
SourceLocation getEndLoc() const LLVM_READONLY
bool containsUnexpandedParameterPack() const
Determine whether this name contains an unexpanded parameter pack.
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)',...
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned RefQualifierIsLValueRef
Whether the ref-qualifier (if any) is an lvalue reference.
DeclSpec * MethodQualifiers
DeclSpec for the function with the qualifier related info.
SourceLocation getRefQualifierLoc() const
Retrieve the location of the ref-qualifier, if any.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
bool hasMethodTypeQualifiers() const
Determine whether this method has qualifiers.
void freeParams()
Reset the parameter list to having zero parameters.
bool hasRefQualifier() const
Determine whether this function declaration contains a ref-qualifier.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@209 Kind
Holds information about the various types of exception specification.
FunctionDecl * SourceDecl
The function whose exception specification this is, for EST_Unevaluated and EST_Uninstantiated.
ExceptionSpecificationType Type
The kind of exception specification this is.
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Expr * NoexceptExpr
Noexcept expression, if this is a computed noexcept specification.
Extra information about a function prototype.
ExceptionSpecInfo ExceptionSpec
RefQualifierKind RefQualifier
FunctionType::ExtInfo ExtInfo
Information about operator rewrites to consider when adding operator functions to a candidate set.
Describes how types, statements, expressions, and declarations should be printed.
A context in which code is being synthesized (where a source location alone is not sufficient to iden...
enum clang::Sema::CodeSynthesisContext::SynthesisKind Kind
SourceLocation PointOfInstantiation
The point of instantiation or synthesis within the source code.
@ MarkingClassDllexported
We are marking a class as __dllexport.
@ InitializingStructuredBinding
We are initializing a structured binding.
@ ExceptionSpecEvaluation
We are computing the exception specification for a defaulted special member function.
@ DeclaringImplicitEqualityComparison
We are declaring an implicit 'operator==' for a defaulted 'operator<=>'.
Decl * Entity
The entity that is being synthesized.
Abstract class used to diagnose incomplete types.
virtual void diagnose(Sema &S, SourceLocation Loc, QualType T)=0
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
OpaquePtr< T > get() const